Commit 77c8b62d authored by Nicolas Dumazet's avatar Nicolas Dumazet

rename InitializePortalTypeClass and make it a metaclass member


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39753 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9071fb3c
...@@ -17,8 +17,10 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -17,8 +17,10 @@ class PortalTypeMetaClass(ExtensionClass):
""" """
Meta class that will be used by portal type classes Meta class that will be used by portal type classes
""" """
# register which classes subclass portal type classes # register which classes subclass portal type classes
subclass_register = {} # XXX ideal defaultdict(list) wannabe subclass_register = {} # XXX ideal defaultdict(list) wannabe
def __init__(cls, name, bases, dictionary): def __init__(cls, name, bases, dictionary):
""" """
This method is called when a portal type class is This method is called when a portal type class is
...@@ -38,19 +40,19 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -38,19 +40,19 @@ class PortalTypeMetaClass(ExtensionClass):
""" """
return metacls.subclass_register.get(cls, []) return metacls.subclass_register.get(cls, [])
def InitializePortalTypeClass(klass): def resetAcquisitionAndSecurity(cls):
# First, fill the __get__ slot of the class # First, fill the __get__ slot of the class
# that has been null'ed after resetting its __bases__ # that has been null'ed after resetting its __bases__
# This descriptor is the magic allowing __of__ and our # This descriptor is the magic allowing __of__ and our
# _aq_dynamic trick # _aq_dynamic trick
pmc_init_of(klass) pmc_init_of(cls)
# Then, call __class_init__ on the class for security # Then, call __class_init__ on the class for security
InitializeClass(klass) InitializeClass(cls)
# And we need to do the same thing on subclasses # And we need to do the same thing on subclasses
for klass in PortalTypeMetaClass.getSubclassList(klass): for subcls in PortalTypeMetaClass.getSubclassList(cls):
pmc_init_of(klass) pmc_init_of(subcls)
InitializeClass(klass) InitializeClass(subcls)
def generateLazyPortalTypeClass(portal_type_name, def generateLazyPortalTypeClass(portal_type_name,
portal_type_class_loader): portal_type_class_loader):
...@@ -81,7 +83,7 @@ def generateLazyPortalTypeClass(portal_type_name, ...@@ -81,7 +83,7 @@ def generateLazyPortalTypeClass(portal_type_name,
for key, value in attributes.iteritems(): for key, value in attributes.iteritems():
setattr(klass, key, value) setattr(klass, key, value)
InitializePortalTypeClass(klass) klass.resetAcquisitionAndSecurity()
return getattr(self, attr) return getattr(self, attr)
......
...@@ -33,7 +33,7 @@ import inspect ...@@ -33,7 +33,7 @@ import inspect
from types import ModuleType from types import ModuleType
from dynamic_module import registerDynamicModule 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.Base import _aq_reset
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
...@@ -308,7 +308,7 @@ def synchronizeDynamicModules(context, force=False): ...@@ -308,7 +308,7 @@ def synchronizeDynamicModules(context, force=False):
if attr != '__module__': if attr != '__module__':
delattr(klass, attr) delattr(klass, attr)
klass.__bases__ = ghostbase klass.__bases__ = ghostbase
InitializePortalTypeClass(klass) klass.resetAcquisitionAndSecurity()
# Clear accessor holders of ZODB Property Sheets # Clear accessor holders of ZODB Property Sheets
_clearAccessorHolderModule(erp5.zodb_accessor_holder) _clearAccessorHolderModule(erp5.zodb_accessor_holder)
......
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