ZODB Components: Likewise Document, add Mixin (erp5.component.mixin) and Interface (erp5.component.interface).
Tests passed: https://nexedi.erp5.net/test_result_module/20190204-2FBF0BAF
@nexedi Before refactoring and cleaning up, I wanted to confirm that having one Interface/Mixin per ZODB Component would be fine (AFAIK there is no convention about that). Because like Documents, this would allow using the reference to list them (such as in BaseType_view
) instead of importing all the modules and then getting the classes of each one of them (not a problem with current filesystems Mixin/Interfaces but costly with ZODB Components, eg modify Portal Type → reset → get all the classes again). Currently, it seems to be the cases for Mixins (or at least most of them) but not for Interfaces where one file sometimes define several Interfaces.
Some background information about current implementation: with filesystem implementation, when listing available Mixins and Interfaces on a Portal Type view (BaseType_view
through respectively getMixinTypeList()
and getInterfaceTypeList()
):
- For Mixins, done on each Product initialization (
Products.ERP5Type.Utils.initializeProduct()
):- Check that the Product has a
mixin
submodule and if it does:- Import the module.
- Get all class members (
inspect.getmembers()
), except Exception classes, and add them tomixin_class_registry
dict later used ingetMixinTypeList()
.
- Check that the Product has a
- For Interfaces, only for ERP5Type Product Interfaces:
- Import Products.ERP5Type.interfaces.
- Return all of its classes (
inspect.getmembers()
) as all Interfaces are explicitely imported in its__init__.py
.