I have an old-style product with several classes. In the class, I have defined the meta_type and I have also registered them in __init__.py, i.e.:
def initialize(context):
context.registerClass(
ClassA.ClassA,
permission = "Add ClassA",
constructors = (ClassA.manage_addClassA,
ClassA.manage_addClassA),
icon = 'www/images/ClassA.gif'
)
This worked fine until I updated my Zope from 2.9 to 2.13. Now in the zmi, in the “Add Products” dropdown list, these meta_types are shown two times each.
I tried to track the source of this error:
- ObjectManager.py, filtered_meta_types
- ObjectManager.py, all_meta_types
- getattr(Products, ‘meta_types’, ())
Now I don’t know where to look next 🙂
It’s only a nuisance, it does not cause any problems in the functionality of the product. Maybe I should update it to a new-style zope product, but I’m curious where this error comes from.
You need to remove your
<five:registerPackage />registration from theconfigure.zcmlfile, because your legacy package is using theProducts.namespace.The
Products.namespace has always been auto-loaded; theinitialize(context)function is implicitly being loaded for that namespace since before it was an official namespace.When Zope started to support packages outside of the
Products.namespace, however, the decision was made (wisely) to make registration explicit instead, and the<five:registerPackage />was introduced to let you use the old registration hook if you still needed it.In your case, however, that means your
initialize()function is being called twice; once because it is aProducts.package, and once because you explicitly registered it.