Commit b95a2cc1 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Load portal type class when trying to access a class attribute and

avoid loading the class if it has already been loaded before


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40578 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 181c9d3a
...@@ -129,7 +129,27 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -129,7 +129,27 @@ class PortalTypeMetaClass(ExtensionClass):
cls.__ghostbase__ = None cls.__ghostbase__ = None
cls.resetAcquisitionAndSecurity() cls.resetAcquisitionAndSecurity()
def __getattr__(cls, name):
"""
Load the class before trying to access a class attribute (for
example, Standard Property document defines a class method to
import a filesystem property)
"""
# Perform the loadClass only on erp5.portal_type classes
if cls.__module__ != 'erp5.portal_type':
return getattr(cls.__bases__[0], name)
if not name.startswith('__') and cls.__ghostbase__ is None:
cls.loadClass()
return getattr(cls, name)
raise AttributeError
def loadClass(cls): def loadClass(cls):
# Do not load the class again if it has already been loaded
if cls.__ghostbase__ is not None:
return
# cls might be a subclass of a portal type class # cls might be a subclass of a portal type class
# we need to find the right class to change # we need to find the right class to change
for klass in cls.__mro__: for klass in cls.__mro__:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment