[Erp5-report] r39753 nicolas.dumazet - /erp5/trunk/products/ERP5Type/dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Nov 2 06:54:57 CET 2010


Author: nicolas.dumazet
Date: Tue Nov  2 06:54:56 2010
New Revision: 39753

URL: http://svn.erp5.org?rev=39753&view=rev
Log:
rename InitializePortalTypeClass and make it a metaclass member

Modified:
    erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
    erp5/trunk/products/ERP5Type/dynamic/portal_type_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=39753&r1=39752&r2=39753&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Tue Nov  2 06:54:56 2010
@@ -17,8 +17,10 @@ class PortalTypeMetaClass(ExtensionClass
   """
   Meta class that will be used by portal type classes
   """
+
   # register which classes subclass portal type classes
   subclass_register = {} # XXX ideal defaultdict(list) wannabe
+
   def __init__(cls, name, bases, dictionary):
     """
     This method is called when a portal type class is
@@ -38,19 +40,19 @@ class PortalTypeMetaClass(ExtensionClass
     """
     return metacls.subclass_register.get(cls, [])
 
-def InitializePortalTypeClass(klass):
-  # First, fill the __get__ slot of the class
-  # that has been null'ed after resetting its __bases__
-  # This descriptor is the magic allowing __of__ and our
-  # _aq_dynamic trick
-  pmc_init_of(klass)
-  # Then, call __class_init__ on the class for security
-  InitializeClass(klass)
-
-  # And we need to do the same thing on subclasses
-  for klass in PortalTypeMetaClass.getSubclassList(klass):
-    pmc_init_of(klass)
-    InitializeClass(klass)
+  def resetAcquisitionAndSecurity(cls):
+    # First, fill the __get__ slot of the class
+    # that has been null'ed after resetting its __bases__
+    # This descriptor is the magic allowing __of__ and our
+    # _aq_dynamic trick
+    pmc_init_of(cls)
+    # Then, call __class_init__ on the class for security
+    InitializeClass(cls)
+
+    # And we need to do the same thing on subclasses
+    for subcls in PortalTypeMetaClass.getSubclassList(cls):
+      pmc_init_of(subcls)
+      InitializeClass(subcls)
 
 def generateLazyPortalTypeClass(portal_type_name,
                                 portal_type_class_loader):
@@ -81,7 +83,7 @@ def generateLazyPortalTypeClass(portal_t
         for key, value in attributes.iteritems():
           setattr(klass, key, value)
 
-        InitializePortalTypeClass(klass)
+        klass.resetAcquisitionAndSecurity()
 
         return getattr(self, attr)
 

Modified: erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py?rev=39753&r1=39752&r2=39753&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] Tue Nov  2 06:54:56 2010
@@ -33,7 +33,7 @@ import inspect
 from types import ModuleType
 
 from dynamic_module import registerDynamicModule
-from lazy_class import generateLazyPortalTypeClass, InitializePortalTypeClass
+from lazy_class import generateLazyPortalTypeClass
 
 from Products.ERP5Type.Base import _aq_reset
 from Products.ERP5Type.Globals import InitializeClass
@@ -308,7 +308,7 @@ def synchronizeDynamicModules(context, f
         if attr != '__module__':
           delattr(klass, attr)
       klass.__bases__ = ghostbase
-      InitializePortalTypeClass(klass)
+      klass.resetAcquisitionAndSecurity()
 
   # Clear accessor holders of ZODB Property Sheets
   _clearAccessorHolderModule(erp5.zodb_accessor_holder)




More information about the Erp5-report mailing list