[Solved] Plone 5.2 py2/3 migration and collective.taxonomy

Hi, anyone out there also having problems with migration from py2 to py3 using bin/zodbupdate if you have used collective.taxonomy?

Traceback (most recent call last):
  File "/Users/peterm/workspace/weitererzaehlen/src/zodbupdate/src/zodbupdate/main.py", line 220, in main
    updater()
  File "/Users/peterm/workspace/weitererzaehlen/src/zodbupdate/src/zodbupdate/update.py", line 87, in __call__
    new = self.processor.rename(current)
  File "/Users/peterm/workspace/weitererzaehlen/src/zodbupdate/src/zodbupdate/serialize.py", line 335, in rename
    data = unpickler.load()
  File "/Users/peterm/workspace/weitererzaehlen/src/zodbupdate/src/zodbupdate/serialize.py", line 201, in __find_global
    return find_global(*self.__update_symb(klass_info), Broken=ZODBBroken)
  File "/Users/peterm/workspace/weitererzaehlen/src/zodbupdate/src/zodbupdate/serialize.py", line 183, in __update_symb
    create_broken_module_for(symb)
  File "/Users/peterm/workspace/weitererzaehlen/src/zodbupdate/src/zodbupdate/serialize.py", line 71, in create_broken_module_for
    setattr(sys.modules[symb.__module__], symb.__name__, symb)
  File "/Users/peterm/workspace/weitererzaehlen/eggs/plone.dexterity-2.10.5-py3.8.egg/plone/dexterity/synchronize.py", line 10, in synchronized_function
    return f(*args, **kw)
  File "/Users/peterm/workspace/weitererzaehlen/src/collective.taxonomy/src/collective/taxonomy/generated.py", line 34, in __setattr__
    raise NotImplementedError(
NotImplementedError: Taxonomy: __setattr__ for generated shouldnot be called!

I'm not sure how to handle those generated taxonomy classes while migrating.

I was able to fix that with the help of this post: Zodbverify: Porting Plone with ZopeDB to Python3 - #15 by mauritsvanrees

I've defined a zodbupdate rename_dict like this in my.addon.__init__.py product:

zodb_rename_dict = {
    'collective.taxonomy.generated interviewort': 'zope.interface Interface',
    'collective.taxonomy.generated ort': 'zope.interface Interface',
    'collective.taxonomy.generated sammlung': 'zope.interface Interface',
    'collective.taxonomy.generated themenfilter': 'zope.interface Interface',
}

then you can wire this with an entry_point in the setup.py of my.addon:

setup(
    ...
    entry_points="""
        ...
        [zodbupdate]
        renames = my.addon:zodb_rename_dict
    """,
    ...
)

now my bin/zodbupdate runs without errors.

1 Like

Short question, the keys of the dict are really defined with spaces?

Yes. See documentation here zodbupdate · PyPI