[Solved] Error while installing collective.z3cform.datagridfield

I am trying to include "collective.z3cform.datagridfield" to the project but it is giving the following error when I click "install" button on the " Add-ons" page (/prefs_install_products_form). I have tried to install different versions of the addon but nothing seems to work so far.

Has anyone encountered with this before or have any tips on how to solve this issue?

Error:

2024-08-27 16:43:54,961 INFO    [Products.GenericSetup.tool:1421][waitress-0] Importing profile profile-collective.z3cform.datagridfield:default with dependency strategy upgrade.
2024-08-27 16:43:54,962 INFO    [Products.GenericSetup.tool:1462][waitress-0] Applying main profile profile-collective.z3cform.datagridfield:default
2024-08-27 16:43:55,022 INFO    [GenericSetup.browserlayer:98][waitress-0] Browser layers imported
2024-08-27 16:43:55,147 ERROR   [Zope.SiteErrorLog:238][waitress-0] 1724769835.14652590.08387969514362037 http://localhost:8080/Plone/install_products
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 391, in publish_module
  Module ZPublisher.WSGIPublisher, line 285, in publish
  Module ZPublisher.mapply, line 98, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 544, in __call__
  Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 310, in install_product
  Module Products.GenericSetup.tool, line 393, in runAllImportStepsFromProfile
   - __traceback_info__: profile-collective.z3cform.datagridfield:default
  Module Products.GenericSetup.tool, line 1504, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 1316, in _doRunImportStep
   - __traceback_info__: plone.app.registry
  Module plone.app.registry.exportimport.handler, line 79, in importRegistry
   - __traceback_info__: registry.xml
  Module plone.app.registry.exportimport.handler, line 125, in importDocument
  Module plone.app.registry.exportimport.handler, line 393, in importRecords
   - __traceback_info__: records name: Products.CMFPlone.interfaces.IBundleRegistry
AttributeError: 'dict' object has no attribute '__identifier__'

Versions:

  • Plone 6.0.10.post0 (6021)
  • CMF 3.3
  • Zope 5.9
  • Python 3.11.9 (main, Apr 2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)]
  • PIL 9.5.0 (Pillow)
  • WSGI: On
  • Server: waitress 2.1.2

collective.z3cform.datagridfield version I am installing is: 3.0.2

It shouldn't make a difference, but here is my current working setup (cookiecutter/pip install):

Version Overview

Plone 6.0.11 (6022)
CMF 3.5
Zope 5.9
Python 3.11.9 (main, Apr 6 2024, 17:59:24) [GCC 9.4.0]
PIL 9.5.0 (Pillow)
WSGI: On
Server: waitress 2.1.2

collective.z3cform.datagridfield 3.0.3.dev0

Clearly, you've to breakpoint on plone.app.registry.exportimport.handler, line 79 and try to guess why you've a dict instead of an interface. You can try also to change in:
collective/z3cform/datagridfield/profiles/default/registry.xml

Products.CMFPlone.interfaces.IBundleRegistry

to

plone.base.interfaces.resources.IBundleRegistry

to see if it helps...

1 Like

you could try to checkout datagridfield and change the deprecated Products.CMFPlone.interfaces.IBundleRegistry into plone.base.interfaces.resources.IBundleRegistry in profiles/default/registry.xml

you were faster :wink:

@yurj and @petschki, thank you so much for your answers.

Your solution worked like a charm and I was able to install it without problem.

Would you mind create a PR with this fix? I'd do a patch release asap ...

I don't understand why it throws an error. It should have worked anyway, right? Maybe the fix works because the entry in the registry is changed, could be that the problem is elsewhere?

I have created the issue and the PR about this:

2 Likes

My guess is that you need to upgrade your CMF version and plone.base, so that it correctly handles the deprecation of IBundleRegistry.

deprecated(
    "Moved to plone.base.interfaces, import from there instead (will be removed in Plone 7).",
    IBundleRegistry="plone.base.interfaces.resources:IBundleRegistry",
[..]
)

I just got this error while installing another addon and fixed it for me.

So I digged a bit into it with bin/instance debug

>>> from Products.CMFPlone import interfaces
>>> interfaces.IPloneSiteRoot
<InterfaceClass plone.base.interfaces.siteroot.IPloneSiteRoot>
>>> interfaces.IBundleRegistry
{}
>>>

? huh ...

All interfaces in Products.CMFPlone.interfaces are marked as deprecated with zope.deferredimport.deprecated. This package has a ModuleProxy which sets the new interface location as attribute with setattr to the old module. So why is every interface working, but IBundleRegistry not?

With a neat trick you can override the __setattr__ of a module (PEP 726 – Module __setattr__ and __delattr__ | peps.python.org) :

from types import ModuleType
import sys

class DebugModule(ModuleType):
    def __setattr__(self, name, value):
        if "IBundleRegistry" in name:
            breakpoint()
        super().__setattr__(name, value)


sys.modules[__name__].__class__ = DebugModule

So I've put this into Products.CMFPlone.interfaces, started the instance again and got the first breakpoint()

[53]   /Users/peterm/workspace/gbd/eggs/plone.app.upgrade-3.1.4-py3.11.egg/plone/app/upgrade/v60/alphas.py(9)<module>()
-> from Products.CMFPlone.interfaces import IBundleRegistry
[54]   <frozen importlib._bootstrap>(1229)_handle_fromlist()
[55]   /Users/peterm/workspace/gbd/eggs/zope.deferredimport-5.0-py3.11.egg/zope/deferredimport/deferredmodule.py(72)__getattr__()
-> setattr(self, name, v)

ok, thats correct since its the first time someone wants to import from the old location. Skip this with continue.

Now that its set, I assume the instance gets started, but hey -> theres another breakpoint coming:

[65]   /Users/peterm/workspace/gbd/eggs/collective.lazysizes-4.1.6-py3.11-macosx-14.0-arm64.egg/collective/lazysizes/upgrades/v10/__init__.py(9)<module>()
-> Products.CMFPlone.interfaces.IBundleRegistry = {}

! aha ...

collective.lazysizes has an upgrade step which is not compatible with Plone 6. When I've removed it from my buildout, the deprecated import returns the Interface correctly and my addon can be installed.

EDIT: The corresponding issue can be found here Something odd with the bundle registration? AttributeError: 'dict' object has no attribute '__identifier__' · Issue #84 · collective/collective.lazysizes · GitHub

1 Like