运行transmogrifier管道并创建新对象时,在创建某些内容类型(例如“文档”-
它在plone.app.transmogrifier.atschemaupdater.py
在此通话中:event.notify(ObjectInitializedEvent(obj))
这非常烦人,因为控制台上没有堆栈跟踪。也很难
进行调试,因为内部有很多Plone和Zope调用在执行动态功能
“订阅事件”。到目前为止,我通过PDB获得了这个stacktrace:
Pdb) zope.component.subscribers((event.object, event), None)
*** Unauthorized: You are not allowed to access 'save' in this context
(Pdb) where
/home/gwidion/.buildout/eggs/Zope2-2.13.15-py2.7.egg/ZServer/PubCore/ZServerPublisher.py(31)__init__()
-> response=b)
/home/gwidion/.buildout/eggs/Zope2-2.13.15-py2.7.egg/ZPublisher/Publish.py(443)publish_module()
-> environ, debug, request, response)
/home/gwidion/.buildout/eggs/Zope2-2.13.15-py2.7.egg/ZPublisher/Publish.py(237)publish_module_standard()
-> response = publish(request, module_name, after_list, debug=debug)
/home/gwidion/.buildout/eggs/Zope2-2.13.15-py2.7.egg/ZPublisher/Publish.py(115)publish()
-> object=request.traverse(path, validated_hook=validated_hook)
/home/gwidion/.buildout/eggs/Zope2-2.13.15-py2.7.egg/ZPublisher/BaseRequest.py(501)traverse()
-> subobject = self.traverseName(object, entry_name)
/home/gwidion/.buildout/eggs/Zope2-2.13.15-py2.7.egg/ZPublisher/BaseRequest.py(326)traverseName()
-> ob2 = namespaceLookup(ns, nm, ob, self)
/home/gwidion/.buildout/eggs/zope.traversing-3.13.2-py2.7.egg/zope/traversing/namespace.py(112)namespaceLookup()
-> return traverser.traverse(name, ())
/home/gwidion/.buildout/eggs/zope.traversing-3.13.2-py2.7.egg/zope/traversing/namespace.py(327)traverse()
-> name=name)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py(120)queryMultiAdapter()
-> return sitemanager.queryMultiAdapter(objects, interface, name, default)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py(238)queryMultiAdapter()
-> objects, interface, name, default)
/home/gwidion/.buildout/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py(532)queryMultiAdapter()
-> result = factory(*objects)
/home/gwidion/simples/carta/plone/src/cartacapital.portal.migration/src/cartacapital/portal/migration/import.py(17)__init__()
-> tr("cartacapital.portal.migration")
/home/gwidion/.buildout/eggs/collective.transmogrifier-1.3-py2.7.egg/collective/transmogrifier/transmogrifier.py(62)__call__()
-> for item in pipeline:
/home/gwidion/.buildout/eggs/plone.app.transmogrifier-1.2-py2.7.egg/plone/app/transmogrifier/atschemaupdater.py(67)__iter__()->{'_path': u'/Plone...economia', '_type': 'Folder', 'debug': None, 'state': 'published', ...}
-> event.notify(ObjectInitializedEvent(obj))
/home/gwidion/.buildout/eggs/zope.event-3.5.2-py2.7.egg/zope/event/__init__.py(31)notify()
-> subscriber(event)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/event.py(24)dispatch()
-> zope.component.subscribers(event, None)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py(136)subscribers()
-> return sitemanager.subscribers(objects, interface)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py(321)subscribers()
-> return self.adapters.subscribers(objects, provided)
/home/gwidion/.buildout/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py(585)subscribers()
-> subscription(*objects)
> /home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/event.py(32)objectEventNotify()
-> zope.component.subscribers((event.object, event), None)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py(136)subscribers()
-> return sitemanager.subscribers(objects, interface)
/home/gwidion/.buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py(321)subscribers()
-> return self.adapters.subscribers(objects, provided)
/home/gwidion/.buildout/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py(585)subscribers()
-> subscription(*objects)
/home/gwidion/.buildout/eggs/Products.CMFEditions-2.2.4-py2.7.egg/Products/CMFEditions/subscriber.py(60)objectInitialized()
-> return webdavObjectEventHandler(obj, event, comment=comment)
/home/gwidion/.buildout/eggs/Products.CMFEditions-2.2.4-py2.7.egg/Products/CMFEditions/subscriber.py(44)webdavObjectEventHandler()
-> maybeSaveVersion(obj, comment=comment, force=False)
/home/gwidion/.buildout/eggs/Products.CMFEditions-2.2.4-py2.7.egg/Products/CMFEditions/utilities.py(123)maybeSaveVersion()
-> pr.save(obj=obj, comment=comment)
/home/gwidion/.buildout/eggs/Products.CMFEditions-2.2.4-py2.7.egg/Products/CMFEditions/CopyModifyMergeRepositoryTool.py(294)save()
-> self._assertAuthorized(obj, SaveNewVersion, 'save')
/home/gwidion/.buildout/eggs/Products.CMFEditions-2.2.4-py2.7.egg/Products/CMFEditions/CopyModifyMergeRepositoryTool.py(428)_assertAuthorized()
-> raise Unauthorized(name)
(Pdb)
到目前为止,我的解决方法是将zope.event.notify修改为no-op
在运行管道之前,但这显然不是这样做的方法。
值得注意的是:我使用视图代码中的函数触发了transmogrifier管道-(当然,我确实以站点管理员的身份加载视图)。
最佳答案
在运行transmogrifier管道时,应禁用版本控制。这是plone.app.transmogrifier
文档中的documented; plone.app.transmogrifier.versioning
蓝图提供了一个简单的插入式配方,用于切换此设置:
[transmogrifier]
pipeline =
schemasource
disable_versioning
constructor
enable_versioning
schemaupdater
[disable_versioning]
blueprint = plone.app.transmogrifier.versioning.disable
[constructor]
blueprint = collective.transmogrifier.sections.constructor
[enable_versioning]
blueprint = plone.app.transmogrifier.versioning.enable
关于python - 使用Transmogrifier在Plone中上载内容时发生未经授权的异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13995273/