Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PersistentAdapterRegistry not compatible with pickle protocol 2 #34

Closed
hannosch opened this issue Sep 18, 2017 · 10 comments
Closed

PersistentAdapterRegistry not compatible with pickle protocol 2 #34

hannosch opened this issue Sep 18, 2017 · 10 comments
Assignees
Labels

Comments

@hannosch
Copy link
Contributor

This was first discussed in unreleated comments in zopefoundation/Zope#188. Putting it here where it belongs:

There's this nice warning message on the pickle protocol page (https://docs.python.org/2/library/pickle.html):

Note: For new-style classes, if getstate() returns a false value, the __setstate__ method will not be called.

The code in https://github.com/zopefoundation/zope.component/blob/master/src/zope/component/persistentregistry.py doesn't work with that for empty registries.

In the __getstate__ it removes all its in-memory-only bits (everything in _delegated), but that means it returns an empty value for an empty registry. When unpickling things, __init__ isn't called, so this code relies on the self._createLookup() to be called as part of __setstate__ to put those in-memory objects back. Only this no longer happens thanks to the empty __getstate__ return value. I think that PersistentAdapterRegistry needs to implement a __new__ to populate its invariants, maybe a __getnewargs__ as well.

@jamadden
Copy link
Member

The original issue is mostly my fault, sorry, I'm the one that switched the default pickle protocol. I'll try to take a look at this soon-ish, unless someone beats me to it.

@hannosch
Copy link
Contributor Author

Nah, thanks for the change. I tried to get Jim to change the default protocol 7 years ago, but didn't convince him at the time (https://github.com/zopefoundation/ZODB/tree/hannosch-pickle-protocol2) ;-)

It should be rare for any classes in the Zope world to implement their own get/setstate, so this issue shouldn't be widespread.

@jamadden jamadden self-assigned this Sep 18, 2017
@jamadden jamadden added the bug label Sep 18, 2017
@jamadden
Copy link
Member

I'm struggling to reproduce this from a fresh state. An empty PersistentAdapterRegistry automatically has a bunch of attributes already in its __getstate__, meaning it's not False:

>>> from zope.component.persistentregistry import PersistentAdapterRegistry
>>> registry = PersistentAdapterRegistry()
>>> registry.__getstate__()
{'__bases__': (),
 '_adapters': [],
 '_generation': 1,
 '_provided': {},
 '_subscribers': []}

I can't find any code in either zope.interface or zope.component that can cope with attributes like _adapters being missing in an unghosted object, so they must always be part of the state. That is, there is no __setstate__ or similar in the MRO of PersistentAdapterRegistry that fills in default values, and there are no default values on the class, and they're not accessed through a getattr-with-default call.

Is there a subclass somewhere in Zope or its dependencies that handles a backwards-incompatible pickle?

@hannosch
Copy link
Contributor Author

Hmm. I cannot reproduce this locally either. There's usually another subclass involved in the Zope 2/4 context from five.localsitemanager. But that doesn't seem to change the behavior either (https://github.com/zopefoundation/five.localsitemanager/blob/master/src/five/localsitemanager/registry.py#L210).

I think we need to wait until we hear from @pbauer and what he can find. Maybe I misdiagnosed the problem completely and something else is at fault.

@pbauer
Copy link
Member

pbauer commented Sep 18, 2017

Reverting to ZODB 5.2.4 had no effect. I guess it is not related to the pickle protocol since Plone 5.1rc1 already uses ZODB 5.3.0 without issues.

Below is the complete output from startup to the traceback. It happens when creating a new Plone Site instance via the view @@plone-addsite.

There are many more exciting errors in http://jenkins.plone.org/view/PLIPs/job/plip-zope4/42/consoleText if you are interested 😉

pbauer@bullet  ~/workspace/coredev   5.1 ●  ./bin/instance fg
/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/Zope2/Startup/starter.py:192: DeprecationWarning: set_default_debug_mode is deprecated. Please import from ZServer.ZPublisher.Publish.
  ZPublisher.Publish.set_default_debug_mode(self.cfg.debug_mode)
/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/Zope2/Startup/starter.py:193: DeprecationWarning: set_default_authentication_realm is deprecated. Please import from ZServer.ZPublisher.Publish.
  ZPublisher.Publish.set_default_authentication_realm(
2017-09-19 00:17:28 INFO ZServer HTTP server started at Tue Sep 19 00:17:28 2017
    Hostname: 0.0.0.0
    Port: 8080
/Users/pbauer/.cache/buildout/eggs/Products.ZSQLMethods-2.13.5-py2.7.egg/Shared/DC/ZRDB/DA.py:40: DeprecationWarning: ResourceLockedError is deprecated. Please import from zExceptions.
  from webdav.Lockable import ResourceLockedError
/Users/pbauer/workspace/coredev/src/Products.CMFCore/Products/CMFCore/FSZSQLMethod.py:20: DeprecationWarning: InitializeClass is deprecated. Please import from AccessControl.class_init.
  from App.class_init import InitializeClass
2017-09-19 00:17:28 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_historyCopy'
2017-09-19 00:17:28 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_afterHistoryCopy'
2017-09-19 00:17:28 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_beforeHistoryCopy'
2017-09-19 00:17:28 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_historyCopy'
2017-09-19 00:17:28 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_afterHistoryCopy'
2017-09-19 00:17:28 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_beforeHistoryCopy'
/Users/pbauer/workspace/coredev/src/Products.CMFCore/Products/CMFCore/CatalogTool.py:23: DeprecationWarning: safe_callable is deprecated. Please import from Products.PluginIndexes.util.
  from Products.PluginIndexes.common import safe_callable
/Users/pbauer/workspace/coredev/src/Products.Archetypes/Products/Archetypes/ReferenceEngine.py:31: DeprecationWarning: LazyMap is deprecated. Please import from ZTUtils.Lazy.
  from Products.ZCatalog.Lazy import LazyMap
/Users/pbauer/workspace/coredev/src/Products.CMFPlone/Products/CMFPlone/earlypatches/security.py:41: DeprecationWarning: ClassDirective is deprecated. Please import from AccessControl.metaconfigure
  from Products.Five.metaconfigure import ClassDirective
/Users/pbauer/.cache/buildout/eggs/plone.app.event-3.0.6-py2.7.egg/plone/app/event/__init__.py:1: DeprecationWarning: setDefaultRoles is deprecated. Please use addPermission from AccessControl.Permission.
  from Products.CMFCore.permissions import setDefaultRoles
/Users/pbauer/workspace/coredev/src/Products.ATContentTypes/Products/ATContentTypes/content/topic.py:35: DeprecationWarning: LazyCat is deprecated. Please import from ZTUtils.Lazy.
  from Products.ZCatalog.Lazy import LazyCat
/Users/pbauer/workspace/coredev/src/Products.ATContentTypes/Products/ATContentTypes/tool/factory.py:28: DeprecationWarning: call_object is deprecated. Please import from ZServer.ZPublisher.Publish.
  from ZPublisher.Publish import call_object
/Users/pbauer/workspace/coredev/src/Products.ATContentTypes/Products/ATContentTypes/tool/factory.py:29: DeprecationWarning: dont_publish_class is deprecated. Please import from ZServer.ZPublisher.Publish.
  from ZPublisher.Publish import dont_publish_class
/Users/pbauer/workspace/coredev/src/Products.ATContentTypes/Products/ATContentTypes/tool/factory.py:30: DeprecationWarning: missing_name is deprecated. Please import from ZServer.ZPublisher.Publish.
  from ZPublisher.Publish import missing_name
/Users/pbauer/.cache/buildout/eggs/plone.app.uuid-1.2-py2.7.egg/plone/app/uuid/utils.py:3: DeprecationWarning: zope.site.hooks has moved to zope.component.hooks. Import of zope.site.hooks will become unsupported in Version 5.0
  from zope.site.hooks import getSite
/Users/pbauer/workspace/coredev/src/Products.ZopeVersionControl/src/Products/ZopeVersionControl/ZopeRepository.py:14: DeprecationWarning: default__class_init__ is deprecated. Please import from AccessControl.class_init.
  from App.class_init import default__class_init__ as InitializeClass
/Users/pbauer/.cache/buildout/eggs/Products.ExternalEditor-2.0.3-py2.7.egg/Products/ExternalEditor/ExternalEditor.py:32: DeprecationWarning: wl_isLocked is deprecated. Please import from OFS.Lockable.
  from webdav.Lockable import wl_isLocked
/Users/pbauer/.cache/buildout/eggs/Products.PluggableAuthService-1.11.0-py2.7.egg/Products/PluggableAuthService/utils.py:26: DeprecationWarning: Forbidden is deprecated. Please import from zExceptions.
  from ZPublisher import Forbidden
/Users/pbauer/.cache/buildout/eggs/Products.PluggableAuthService-1.11.0-py2.7.egg/Products/PluggableAuthService/plugins/NotCompetentHelper.py:29: DeprecationWarning: Response is deprecated. Please import from ZPublisher.HTTPResponse
  from ZPublisher.Response import Response
/Users/pbauer/.cache/buildout/eggs/plone.app.blob-1.7.2-py2.7.egg/plone/app/blob/field.py:32: DeprecationWarning: rfc1123_date is deprecated. Please import from App.Common.
  from webdav.common import rfc1123_date
/Users/pbauer/.cache/buildout/eggs/plone.app.blob-1.7.2-py2.7.egg/plone/app/blob/content.py:23: DeprecationWarning: MimeTypeException is deprecated. Import from Products.MimetypesRegistry.interfaces instead
  from Products.MimetypesRegistry.common import MimeTypeException
/Users/pbauer/.cache/buildout/eggs/plone.locking-2.2-py2.7.egg/plone/locking/lockable.py:10: DeprecationWarning: LockItem is deprecated. Please import from OFS.LockItem.
  from webdav.LockItem import LockItem
/Users/pbauer/.cache/buildout/eggs/plone.app.viewletmanager-2.0.10-py2.7.egg/plone/app/viewletmanager/manager.py:22: DeprecationWarning: Retry is deprecated. Please import from ZPublisher.
  from ZPublisher.Publish import Retry
/Users/pbauer/.cache/buildout/eggs/zope.configuration-4.1.0-py2.7.egg/zope/configuration/config.py:165: DeprecationWarning: LockableItem is deprecated. Please import from OFS.Lockable.
  obj = getattr(mod, oname)
/Users/pbauer/workspace/coredev/src/plone.app.dexterity/plone/app/dexterity/__init__.py:14: DeprecationWarning: Name clash, now use '_' as usual. Will be removed in Plone 5.2
  DeprecationWarning)
/Users/pbauer/workspace/coredev/src/plone.app.contenttypes/plone/app/contenttypes/migration/patches.py:13: DeprecationWarning: _marker is deprecated. Please import from Products.PluginIndexes.unindex.
  from Products.PluginIndexes.common.UnIndex import _marker
/Users/pbauer/workspace/coredev/src/plone.app.multilingual/src/plone/app/multilingual/browser/migrator.py:11: DeprecationWarning: LanguageRootFolder: LanguageRootFolders should be migrate to DexterityContainers
  from plone.app.multilingual.content.lrf import LanguageRootFolder
/Users/pbauer/.cache/buildout/eggs/plone.portlet.collection-3.2-py2.7.egg/plone/portlet/collection/collection.py:2: DeprecationWarning: isDefaultPage is deprecated. Import from Products.CMFPlone instead
  from plone.app.layout.navigation.defaultpage import isDefaultPage
/Users/pbauer/workspace/coredev/src/Products.CMFPlone/Products/CMFPlone/browser/syndication/views.py:17: DeprecationWarning: wrap_form is deprecated. Import from plone.z3cform.layout instead.
  from plone.app.z3cform.layout import wrap_form
2017-09-19 00:17:35 WARNING Init Class Products.Five.browser.metaconfigure.+ has a security declaration for nonexistent method 'action.html'
2017-09-19 00:17:35 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_historyCopy'
2017-09-19 00:17:35 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_afterHistoryCopy'
2017-09-19 00:17:35 WARNING Init Class Products.PythonScripts.PythonScript.PythonScript has a security declaration for nonexistent method 'manage_beforeHistoryCopy'
2017-09-19 00:17:36 INFO Zope Ready to handle requests
/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/PubCore/ZServerPublisher.py:21: DeprecationWarning: publish_module is deprecated. Please import from ZServer.ZPublisher.Publish.
  from ZPublisher.Publish import publish_module
2017-09-19 00:17:53 INFO Products.CMFPlone CSRF protection disabled on initial site creation
2017-09-19 00:17:53 INFO Products.GenericSetup.tool Importing profile profile-Products.CMFPlone:plone with dependency strategy upgrade.
2017-09-19 00:17:53 INFO Products.GenericSetup.tool Applying main profile profile-Products.CMFPlone:plone
2017-09-19 00:17:53 INFO Products.GenericSetup.tool Profile upgrade versions purged.
2017-09-19 00:17:53 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:53 INFO GenericSetup.properties Site properties imported.
2017-09-19 00:17:53 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:53 INFO GenericSetup.componentregistry Adapters purged.
2017-09-19 00:17:53 INFO GenericSetup.componentregistry Subscribers purged.
2017-09-19 00:17:53 INFO GenericSetup.componentregistry Utilities purged.
2017-09-19 00:17:53 INFO GenericSetup.componentregistry Adapters registered.
2017-09-19 00:17:53 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:53 INFO GenericSetup.controlpanel Control panel imported.
2017-09-19 00:17:53 INFO GenericSetup.repositorytool Nothing to import.
2017-09-19 00:17:53 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:53 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:53 INFO GenericSetup.memberdata Member data tool imported.
2017-09-19 00:17:53 INFO GenericSetup.memberdata MemberData tool imported.
2017-09-19 00:17:53 INFO GenericSetup.mailhost Mailhost imported.
2017-09-19 00:17:53 INFO GenericSetup.propertiestool Properties tool imported.
2017-09-19 00:17:53 INFO GenericSetup.plone.app.viewletmanager Imported.
2017-09-19 00:17:53 INFO Products.GenericSetup.tool Importing profile profile-Products.CMFPlone:dependencies with dependency strategy upgrade.
2017-09-19 00:17:53 INFO Products.GenericSetup.tool Applying profile profile-Products.CMFFormController:CMFFormController
2017-09-19 00:17:53 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:53 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:53 INFO GenericSetup.repositorytool Nothing to import.
2017-09-19 00:17:53 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:53 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:53 INFO Products.GenericSetup.tool Applying profile profile-Products.MimetypesRegistry:MimetypesRegistry
2017-09-19 00:17:53 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:54 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:54 INFO GenericSetup.componentregistry Adapters registered.
2017-09-19 00:17:54 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:54 INFO GenericSetup.repositorytool Nothing to import.
2017-09-19 00:17:54 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:54 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:54 INFO Products.GenericSetup.tool Applying profile profile-Products.PortalTransforms:PortalTransforms
2017-09-19 00:17:54 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:54 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:54 INFO GenericSetup.componentregistry Adapters registered.
2017-09-19 00:17:54 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:54 INFO GenericSetup.repositorytool Nothing to import.
2017-09-19 00:17:54 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:54 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:54 INFO Products.GenericSetup.tool Applying profile profile-Products.CMFEditions:CMFEditions
2017-09-19 00:17:54 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:54 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:54 INFO GenericSetup.componentregistry Adapters registered.
2017-09-19 00:17:54 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:54 INFO GenericSetup. RepositoryTool settings imported.
2017-09-19 00:17:54 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:54 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:54 INFO Products.GenericSetup.tool Applying profile profile-Products.PlonePAS:PlonePAS
2017-09-19 00:17:54 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:54 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:54 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:54 INFO PluggableAuthService.upgrade.replaceRootUserFolder Capturing user info for admin
2017-09-19 00:17:54 INFO PluggableAuthService.upgrade.replaceRootUserFolder Translating user admin
2017-09-19 00:17:54 INFO PluggableAuthService.upgrade.replaceRootUserFolder Replaced root acl_users with PluggableAuthService
2017-09-19 00:17:55 INFO PluggableAuthService.upgrade.upgradeLocalRoleAssignmentsFromRoot   Translated admin to admin
2017-09-19 00:17:55 INFO PluggableAuthService.upgrade.upgradeLocalRoleAssignmentsFromRoot   Assigned roles ['Owner'] to admin
... 
more of the same 
...
2017-09-19 00:17:55 INFO PluggableAuthService.upgrade.replace_acl_users Root acl_users has been replaced, and local role assignments updated.
2017-09-19 00:17:55 INFO Products.GenericSetup.tool Applying profile profile-plone.app.z3cform:default
2017-09-19 00:17:55 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:55 INFO GenericSetup.plone.app.registry Cannot find registry
2017-09-19 00:17:55 INFO GenericSetup.bundles Cannot find registry
2017-09-19 00:17:55 INFO GenericSetup.browserlayer Browser layers imported
2017-09-19 00:17:55 INFO Products.GenericSetup.tool Applying profile profile-plone.app.registry:default
2017-09-19 00:17:55 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:55 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:55 INFO GenericSetup.componentregistry Adapters registered.
2017-09-19 00:17:55 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:55 INFO GenericSetup.controlpanel Control panel imported.
2017-09-19 00:17:55 INFO Products.GenericSetup.tool Applying profile profile-plone.app.discussion:default
2017-09-19 00:17:55 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:55 INFO GenericSetup.controlpanel Control panel imported.
2017-09-19 00:17:55 INFO GenericSetup.resourceregistry Javascript registry imported.
2017-09-19 00:17:55 INFO GenericSetup.browserlayer Browser layers imported
2017-09-19 00:17:55 INFO Products.GenericSetup.tool Applying profile profile-plone.app.intid:default
2017-09-19 00:17:55 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.app.relationfield:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.app.linkintegrity:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.resource:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO GenericSetup.toolset Toolset imported.
2017-09-19 00:17:56 INFO GenericSetup.componentregistry Adapters registered.
2017-09-19 00:17:56 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.app.theming:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO GenericSetup.controlpanel Control panel imported.
2017-09-19 00:17:56 INFO GenericSetup.browserlayer Browser layers imported
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.app.users:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO plone.app.users.setuphandlers Imported schema
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.outputfilters:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.app.querystring:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.portlet.collection:default
2017-09-19 00:17:56 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:56 INFO GenericSetup.portlets Portlets imported
2017-09-19 00:17:56 INFO Products.GenericSetup.tool Applying profile profile-plone.portlet.static:default
2017-09-19 00:17:57 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:57 INFO GenericSetup.portlets Portlets imported
2017-09-19 00:17:57 INFO Products.GenericSetup.tool Applying profile profile-plone.keyring:default
2017-09-19 00:17:57 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:57 INFO GenericSetup.componentregistry Utilities registered.
2017-09-19 00:17:57 INFO Products.GenericSetup.tool Applying profile profile-plone.protect:default
2017-09-19 00:17:57 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:57 INFO Products.GenericSetup.tool Applying main profile profile-Products.CMFPlone:dependencies
2017-09-19 00:17:57 INFO GenericSetup.rolemap Role / permission map imported.
2017-09-19 00:17:57 INFO GenericSetup.controlpanel Control panel imported.
2017-09-19 00:17:58 ERROR ZServerPublisher exception caught
Traceback (most recent call last):
  File "/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/PubCore/ZServerPublisher.py", line 31, in __init__
    response=b)
  File "/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/ZPublisher/Publish.py", line 412, in publish_module
    environ, debug, request, response)
  File "/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/ZPublisher/Publish.py", line 300, in publish_module_standard
    request.close()
  File "/Users/pbauer/workspace/coredev/src/Zope/src/ZPublisher/BaseRequest.py", line 220, in close
    notify(EndRequestEvent(None, self))
  File "/Users/pbauer/.cache/buildout/eggs/zope.event-4.3.0-py2.7.egg/zope/event/__init__.py", line 32, in notify
    subscriber(event)
  File "/Users/pbauer/.cache/buildout/eggs/zope.component-4.4.0-py2.7.egg/zope/component/event.py", line 27, in dispatch
    component_subscribers(event, None)
  File "/Users/pbauer/.cache/buildout/eggs/zope.component-4.4.0-py2.7.egg/zope/component/_api.py", line 139, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/Users/pbauer/.cache/buildout/eggs/zope.interface-4.4.2-py2.7-macosx-10.12-x86_64.egg/zope/interface/registry.py", line 442, in subscribers
    return self.adapters.subscribers(objects, provided)
AttributeError: 'PersistentAdapterRegistry' object has no attribute 'subscribers'
2017-09-19 00:17:58 ERROR ZServerPublisher exception caught
Traceback (most recent call last):
  File "/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/PubCore/ZServerPublisher.py", line 31, in __init__
    response=b)
  File "/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/ZPublisher/Publish.py", line 412, in publish_module
    environ, debug, request, response)
  File "/Users/pbauer/.cache/buildout/eggs/ZServer-4.0a2-py2.7.egg/ZServer/ZPublisher/Publish.py", line 300, in publish_module_standard
    request.close()
  File "/Users/pbauer/workspace/coredev/src/Zope/src/ZPublisher/BaseRequest.py", line 220, in close
    notify(EndRequestEvent(None, self))
  File "/Users/pbauer/.cache/buildout/eggs/zope.event-4.3.0-py2.7.egg/zope/event/__init__.py", line 32, in notify
    subscriber(event)
  File "/Users/pbauer/.cache/buildout/eggs/zope.component-4.4.0-py2.7.egg/zope/component/event.py", line 27, in dispatch
    component_subscribers(event, None)
  File "/Users/pbauer/.cache/buildout/eggs/zope.component-4.4.0-py2.7.egg/zope/component/_api.py", line 139, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/Users/pbauer/.cache/buildout/eggs/zope.interface-4.4.2-py2.7-macosx-10.12-x86_64.egg/zope/interface/registry.py", line 442, in subscribers
    return self.adapters.subscribers(objects, provided)
AttributeError: 'PersistentAdapterRegistry' object has no attribute 'subscribers'

@jamadden
Copy link
Member

I'm not a Plone or Zope[2] guy, so I don't really know what all would be going on in that view, or the lifecycle of that request. If you feel like doing some debugging, some questions I had were:

  • What are the contents of self.adapters.__dict__?
  • Does self.adapters have a _p_oid and _p_mtime? What's its _p_status? (Basically, was this object persisted and unpickled, or is it new and something just neglected to call the correct __init__? I understand that there was a recent change from old-style classes to new-style classes, and I'm wondering if that changed the MRO somewhere relevant such that a constructor is not being called.)

@pbauer
Copy link
Member

pbauer commented Sep 19, 2017

Found it! It is a issue with trying to publish this error-message (grabbed from response in ZServer.ZPublisher.Publish.publish_module):

[1] > /Users/pbauer/.cache/buildout/eggs/ZServer-4.0b1-py2.7.egg/ZServer/ZPublisher/Publish.py(405)publish_module()
-> environ, debug, request, response)
(Pdb++) print response
HTTP/1.1 500 Internal Server Error
Server: Zope/(4.0b2.dev0, python 2.7.13, darwin) ZServer/1.1
Date: Tue, 19 Sep 2017 06:50:50 GMT
Bobo-Exception-Line: 338
Content-Length: 2935
Bobo-Exception-Value: See the server error log for details
Content-Type: text/html; charset=utf-8
Bobo-Exception-Type: <class 'zope.schema._bootstrapinterfaces.ConstraintNotSatisfied'>
X-Frame-Options: SAMEORIGIN
Bobo-Exception-File: _field.py

<!DOCTYPE html>
<html>
  <head><title>Site Error</title><meta charset="utf-8"></head>
  <body bgcolor="#FFFFFF">
  <h2>Site Error</h2>
  <p>An error was encountered while publishing this resource.
  </p>
  <p><strong><class></class></strong></p>
  Sorry, a site error occurred.<p></p><p>Traceback (innermost last):</p>
<ul>
<li>  Module ZServer.ZPublisher.Publish, line 144, in publish</li>
<li>  Module ZPublisher.mapply, line 85, in mapply</li>
<li>  Module ZServer.ZPublisher.Publish, line 44, in call_object</li>
<li>  Module Products.CMFPlone.browser.admin, line 272, in __call__</li>
<li>  Module Products.CMFPlone.factory, line 146, in addPloneSite</li>
<li>  Module Products.GenericSetup.tool, line 388, in runAllImportStepsFromProfile<br>
__traceback_info__: profile-Products.CMFPlone:plone</li>
<li>  Module Products.GenericSetup.tool, line 1442, in _runImportStepsFromContext</li>
<li>  Module Products.GenericSetup.tool, line 1289, in _doRunHandler</li>
<li>  Module Products.CMFPlone.setuphandlers, line 168, in importFinalSteps</li>
<li>  Module Products.GenericSetup.tool, line 388, in runAllImportStepsFromProfile<br>
__traceback_info__: profile-Products.CMFPlone:dependencies</li>
<li>  Module Products.GenericSetup.tool, line 1433, in _runImportStepsFromContext</li>
<li>  Module Products.GenericSetup.tool, line 1245, in _doRunImportStep<br>
__traceback_info__: portlets</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 781, in importPortlets</li>
<li>  Module Products.GenericSetup.utils, line 512, in _importBody</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 301, in _importNode</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 310, in _initProvider</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 364, in _initPortlets</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 535, in _initAssignmentNode<br>
__traceback_info__: Assignment name: actions</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 168, in import_assignment</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 213, in import_node<br>
__traceback_info__: Property name: category</li>
<li>  Module plone.app.portlets.exportimport.portlets, line 255, in from_unicode</li>
<li>  Module zope.schema._field, line 322, in fromUnicode</li>
<li>  Module zope.schema._bootstrapfields, line 183, in validate</li>
<li>  Module zope.schema._field, line 338, in _validate</li>
</ul><p>ConstraintNotSatisfied: (u'site_actions', 'category')
</p>
  <hr noshade>
  <p>Troubleshooting Suggestions</p>
  <ul>
  <li>The URL may be incorrect.</li>
  <li>The parameters passed to this resource may be incorrect.</li>
  <li>A resource that this resource relies on may be
      encountering an error.</li>
  </ul>
  <p>If the error persists please contact the site maintainer.
  Thank you for your patience.
  </p></body></html>

The actions-portlet is somehow broken but that an a different issue...

My first guess is that the change in exception-view-handling (zopefoundation/Zope#102) is to blame. There ,ay also be stuff from zopefoundation/Zope#174 missing (discussed in plone/Products.CMFPlone#1351 (comment)).

@hannosch
Copy link
Contributor Author

Ok. I've managed to reproduce this locally. There is no issue with zope.component here.

It looks like it's an issue with plone.testing and its layer setup. One of the earlier layers fails with the above mentioned ConstraintNotSatisfied error. One of the later layers than runs and encounters a half-setup component registry. It's a persistent component registry, set as current via zope.component.hooks.setSite, without the corresponding db connection ever being committed (as it failed half-way).

To make things more interesting, the __bases__ of that component registry has two more entries for persistent registries from multiple stacked demo storages.

If I get rid of the broken registry via zope.component.hooks.setSite(None) the later code runs through, but probably breaks test layer isolation further.

I think this issue can be closed here, unless someone thinks moving the invariant setup (self._createLookup()) into a __new__ is still worth it.

@jamadden
Copy link
Member

jamadden commented Sep 19, 2017

I think this issue can be closed here, unless someone thinks moving the invariant setup (self._createLookup()) into a new is still worth it.

I think it's probably fine where it is. Pickle protocols less than 2 won't call __new__ (and not everybody that uses persistent uses ZODB, e.g., https://github.com/zopefoundation/mongopersist [technically that doesn't even use pickle, I know, but it uses the support mechanisms]) so it's probably best not to introduce a dependency on the pickle protocol version when we can avoid it.

>>> import cPickle
>>> class Foo(object):
...     def __new__(cls):
...         print("I'm new!")
...         return object.__new__(cls)
...     def __getstate__(self):
...         return (1,)
...     def __setstate__(self, state):
...         print("Got state", state)
...
>>> foo = Foo()
I'm new!
>>> cPickle.loads(cPickle.dumps(foo, 1)) # Notice no __new__ called.
Got state (1,)
<__main__.Foo object at 0x10666a810>
>>> cPickle.loads(cPickle.dumps(foo, 2)) # This time it is.
I'm new!
Got state (1,)
<__main__.Foo object at 0x10666a8d0>
>>> def newargs(obj):
...     print("Getting newargs")
...     return ()
...
>>> Foo.__getnewargs__ = newargs
>>> cPickle.dumps(foo, 1) # Notice no __getnewargs__ called
'ccopy_reg\n_reconstructor\...'
>>> cPickle.loads(cPickle.dumps(foo, 2)) # They're both called
Getting newargs
I'm new!
Got state (1,)
<__main__.Foo object at 0x10666a8d0>

@mgedmin mgedmin closed this as completed Sep 19, 2017
@pbauer
Copy link
Member

pbauer commented Sep 19, 2017

For the curious: The reason for the orginal error was that portal tools are now utilities in recent CMFCore versions. Plone did not yet register these utilities, they could not be found and no action-categories were added on site-creation and so on...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants