• Arnaud Fontaine's avatar
    ZODB Components: Resetting Portal Type classes was also clearing Interfaces of... · 3c42c5ef
    Arnaud Fontaine authored
    ZODB Components: Resetting Portal Type classes was also clearing Interfaces of erp5.component.* modules.
    
    __implemented__ and __provides__ attributes are cleared on Portal Type reset
    to break a circular reference (11e2b506). Resetting of ZODB Components is
    done independently of Portal Type classes, so until the next ZODB Component
    reset, Interfaces were not implemented anymore.
    
    11e2b506 states that this creates a memory leak but this is not actually true
    as Python garbage collector will break such circular reference and collect
    this object, as asserted by a newly introduced Unit Test. This is probably
    less efficient than explicitly breaking the circular reference and thus relies
    on reference counting (rather than the garbage collector) but doing otherwise
    would require introspecting ZODB Components module to find classes implementing
    Interfaces (erp5.portal_type only contains classes).
    
    This only takes care of ZODB Components modules but maybe breaking circular
    references for Portal Type classes is not even needed (if so, this will be done
    in a later commit).
    3c42c5ef
testDynamicClassGeneration.py 120 KB