Zodbverify: Porting Plone with ZopeDB to Python3

I tried zodbverify on a small site and ran into similar errors as above.
In a site-specific package I now have a file with these patches, which make zodbverify and zodbupdate work:

from plone.alterego.interfaces import IDynamicObjectFactory
from plone.app.upgrade.utils import alias_module
from plone.dexterity.schema import SchemaModuleFactory
from zope.component.hooks import getSiteManager
from zope.interface import Interface


try:
    from App.interfaces import IPersistentExtra  # noqa
except ImportError:
    class IPersistentExtra(Interface):
        pass
    alias_module('App.interfaces.IPersistentExtra', IPersistentExtra)

try:
    from App.interfaces import IUndoSupport  # noqa
except ImportError:
    class IUndoSupport(Interface):
        pass
    alias_module('App.interfaces.IUndoSupport', IUndoSupport)

try:
    from Products.ResourceRegistries.interfaces.settings import IResourceRegistriesSettings  # noqa
except ImportError:
    class IResourceRegistriesSettings(Interface):
        pass
    alias_module('Products.ResourceRegistries.interfaces.settings.IResourceRegistriesSettings', IResourceRegistriesSettings)

try:
    from webdav.interfaces import IFTPAccess  # noqa
except ImportError:
    class IFTPAccess(Interface):
        pass
    alias_module('webdav.interfaces.IFTPAccess', IFTPAccess)

try:
    from webdav.EtagSupport import EtagBaseInterface  # noqa
except ImportError:
    class EtagBaseInterface(Interface):
        pass
    alias_module('webdav.EtagSupport.EtagBaseInterface', EtagBaseInterface)


# Register the dynamic schema utility.
sm = getSiteManager()
sm.registerUtility(factory=SchemaModuleFactory, name="plone.dexterity.schema.generated")

See Migration to Plone 5.2 - ZODB to py3 - zodbverify for a small bit of information about the utility at the end.

For the rest, I use alias_module. For that, I am wondering which is better: create a specific dummy interface (for example IPersistentExtra in the first patch), or simply use zope.interface.Interface.

With a specific interface:

  • Good: You can use the specific interface to search for items that have this interface, so you have a chance to clean it up.
  • Bad: you need to keep the new specific interface around forever. You could remove the alias though.

With simply Interface:

  • Good: you only need the alias during migration. You can remove the code afterwards.
  • Bad: any code that checks if an object implements for example IPersistentExtra, will find that all objects implement it, because all objects implement Interface. But after migration, you could remove the alias.

How are people handing this?

2 Likes