When running a transmogrifier pipeline, and creating new objects, I get an Unauthorized exception on creating certain content types (for example "Document" -
it is raised at plone.app.transmogrifier.atschemaupdater.py
on this call: event.notify(ObjectInitializedEvent(obj))
It is extremely annoying because there is no stack trace on the console. It is also hard to debug, since there are a lot of inner Plone and Zope calls doing dynamic functions that "subscribe to events". So far I got this stacktrace with the PDB:
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)
My workaround to this up to now has been monkeypatching zope.event.notify to a no-op prior to running the pipeline, but that is obviously not the way to do it.
Of note: I trigger the transmogrifier pipeline with a function in a view's code - (and I do load the view as site admin, of course).
You should disable versioning when running a transmogrifier pipeline. This is documented in the plone.app.transmogrifier
documentation; the plone.app.transmogrifier.versioning
blueprint offers an easy drop-in recipe for toggling this:
[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