Commit 50d94f29 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Avoid loading the class when restoring a portal type to a ghost state


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40574 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b48df6de
...@@ -50,6 +50,7 @@ class GhostPortalType(ERP5Base): #SimpleItem ...@@ -50,6 +50,7 @@ class GhostPortalType(ERP5Base): #SimpleItem
'__module__', '__module__',
'__name__', '__name__',
'__repr__', '__repr__',
'__ghostbase__',
'__str__') or attr[:3] in ('_p_', '_v_'): '__str__') or attr[:3] in ('_p_', '_v_'):
return super(GhostPortalType, self).__getattribute__(attr) return super(GhostPortalType, self).__getattribute__(attr)
#LOG("ERP5Type.Dynamic", BLATHER, #LOG("ERP5Type.Dynamic", BLATHER,
...@@ -78,6 +79,7 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -78,6 +79,7 @@ class PortalTypeMetaClass(ExtensionClass):
if issubclass(type(parent), PortalTypeMetaClass): if issubclass(type(parent), PortalTypeMetaClass):
PortalTypeMetaClass.subclass_register.setdefault(parent, []).append(cls) PortalTypeMetaClass.subclass_register.setdefault(parent, []).append(cls)
cls.__ghostbase__ = None
super(PortalTypeMetaClass, cls).__init__(name, bases, dictionary) super(PortalTypeMetaClass, cls).__init__(name, bases, dictionary)
@classmethod @classmethod
...@@ -116,12 +118,15 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -116,12 +118,15 @@ class PortalTypeMetaClass(ExtensionClass):
InitializeClass(subclass) InitializeClass(subclass)
def restoreGhostState(cls): def restoreGhostState(cls):
ghostbase = getattr(cls, '__ghostbase__', None) if cls.__ghostbase__ is not None:
if ghostbase is not None:
for attr in cls.__dict__.keys(): for attr in cls.__dict__.keys():
if attr not in ('__module__', '__doc__',): if attr not in ('__module__',
'__doc__',
'__ghostbase__',
'portal_type'):
delattr(cls, attr) delattr(cls, attr)
cls.__bases__ = ghostbase cls.__bases__ = cls.__ghostbase__
cls.__ghostbase__ = None
cls.resetAcquisitionAndSecurity() cls.resetAcquisitionAndSecurity()
def loadClass(cls): def loadClass(cls):
...@@ -150,7 +155,7 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -150,7 +155,7 @@ class PortalTypeMetaClass(ExtensionClass):
# save the old bases to be able to restore a ghost state later # save the old bases to be able to restore a ghost state later
if not hasattr(klass, '__ghostbase__'): if klass.__ghostbase__ is None:
# but only do it if we're in the innermost call, otherwise # but only do it if we're in the innermost call, otherwise
# klass.__bases__ might just be the Document without accessor # klass.__bases__ might just be the Document without accessor
# holders, and we would override the real ghost class # holders, and we would override the real ghost class
......
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