[Erp5-report] r40574 arnaud.fontaine - /erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Nov 24 07:12:55 CET 2010
Author: arnaud.fontaine
Date: Wed Nov 24 07:12:55 2010
New Revision: 40574
URL: http://svn.erp5.org?rev=40574&view=rev
Log:
Avoid loading the class when restoring a portal type to a ghost state
Modified:
erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
Modified: erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/lazy_class.py?rev=40574&r1=40573&r2=40574&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Wed Nov 24 07:12:55 2010
@@ -50,6 +50,7 @@ class GhostPortalType(ERP5Base): #Simple
'__module__',
'__name__',
'__repr__',
+ '__ghostbase__',
'__str__') or attr[:3] in ('_p_', '_v_'):
return super(GhostPortalType, self).__getattribute__(attr)
#LOG("ERP5Type.Dynamic", BLATHER,
@@ -78,6 +79,7 @@ class PortalTypeMetaClass(ExtensionClass
if issubclass(type(parent), PortalTypeMetaClass):
PortalTypeMetaClass.subclass_register.setdefault(parent, []).append(cls)
+ cls.__ghostbase__ = None
super(PortalTypeMetaClass, cls).__init__(name, bases, dictionary)
@classmethod
@@ -116,12 +118,15 @@ class PortalTypeMetaClass(ExtensionClass
InitializeClass(subclass)
def restoreGhostState(cls):
- ghostbase = getattr(cls, '__ghostbase__', None)
- if ghostbase is not None:
+ if cls.__ghostbase__ is not None:
for attr in cls.__dict__.keys():
- if attr not in ('__module__', '__doc__',):
+ if attr not in ('__module__',
+ '__doc__',
+ '__ghostbase__',
+ 'portal_type'):
delattr(cls, attr)
- cls.__bases__ = ghostbase
+ cls.__bases__ = cls.__ghostbase__
+ cls.__ghostbase__ = None
cls.resetAcquisitionAndSecurity()
def loadClass(cls):
@@ -150,7 +155,7 @@ class PortalTypeMetaClass(ExtensionClass
# 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
# klass.__bases__ might just be the Document without accessor
# holders, and we would override the real ghost class
More information about the Erp5-report
mailing list