Skip to content

ZODB Components: Likewise Document, add Mixin (erp5.component.mixin) and Interface (erp5.component.interface).

Arnaud Fontaine requested to merge arnau-TM-components-Interface-Mixin into master

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:
      1. Import the module.
      2. Get all class members (inspect.getmembers()), except Exception classes, and add them to mixin_class_registry dict later used in getMixinTypeList().
  • For Interfaces, only for ERP5Type Product Interfaces:
    1. Import Products.ERP5Type.interfaces.
    2. Return all of its classes (inspect.getmembers()) as all Interfaces are explicitely imported in its __init__.py.

Merge request reports