Commit 74014584 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Again, slightly optimize _aq_dynamic. Also, fix undefined names.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17757 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c9662b1e
...@@ -145,7 +145,7 @@ class WorkflowMethod(Method): ...@@ -145,7 +145,7 @@ class WorkflowMethod(Method):
# critical sections in this part of the code and a # critical sections in this part of the code and a
# thread variable which tells in which semantic context the code # thread variable which tells in which semantic context the code
# should ne executed. - XXX # should ne executed. - XXX
return self_m(instance, *args, **kw) return self._m(instance, *args, **kw)
# New implementation does not use any longer wrapWorkflowMethod # New implementation does not use any longer wrapWorkflowMethod
# but directly calls the workflow methods # but directly calls the workflow methods
...@@ -278,8 +278,9 @@ global method_registration_cache ...@@ -278,8 +278,9 @@ global method_registration_cache
method_registration_cache = {} method_registration_cache = {}
WORKFLOW_METHOD_MARKER = ('Base._doNothing',) WORKFLOW_METHOD_MARKER = ('Base._doNothing',)
RESERVED_TUPLE_PROPERTY = ('_constraints', '_properties', '_categories', RESERVED_TUPLE_PROPERTY = set(('_constraints', '_properties', '_categories',
'__implements__', 'property_sheets', '_erp5_properties' ) '__implements__', 'property_sheets',
'_erp5_properties'))
# It might be necessary to use another type for those reserved properties # It might be necessary to use another type for those reserved properties
# ex. list type # ex. list type
...@@ -641,7 +642,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder): ...@@ -641,7 +642,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder):
else: else:
LOG('initializePortalTypeDynamicWorkflowMethods', 100, LOG('initializePortalTypeDynamicWorkflowMethods', 100,
'WARNING! Can not initialize %s on %s' % \ 'WARNING! Can not initialize %s on %s' % \
(method_id, str(work_method_holder))) (method_id, str(klass)))
else: else:
prop_holder.security.declareProtected(Permissions.AccessContentsInformation, prop_holder.security.declareProtected(Permissions.AccessContentsInformation,
method_id) method_id)
...@@ -691,7 +692,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder): ...@@ -691,7 +692,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder):
else: else:
LOG('initializePortalTypeDynamicWorkflowMethods', 100, LOG('initializePortalTypeDynamicWorkflowMethods', 100,
'WARNING! Can not initialize %s on %s' % \ 'WARNING! Can not initialize %s on %s' % \
(method_id, str(work_method_holder))) (method_id, str(klass)))
else: else:
prop_holder.security.declareProtected(Permissions.AccessContentsInformation, prop_holder.security.declareProtected(Permissions.AccessContentsInformation,
method_id) method_id)
...@@ -829,24 +830,18 @@ class Base( CopyContainer, ...@@ -829,24 +830,18 @@ class Base( CopyContainer,
# If this is a portal_type property and everything is already defined # If this is a portal_type property and everything is already defined
# for that portal_type, try to return a value ASAP # for that portal_type, try to return a value ASAP
if aq_key in Base.aq_portal_type: try:
property_holder = Base.aq_portal_type[aq_key] property_holder = Base.aq_portal_type[aq_key]
accessor = getattr(property_holder, id, None) accessor = getattr(property_holder, id, None)
if accessor is not None: if isinstance(accessor, tuple):
# Clearly this below has a bad effect in CMFCategory. if id not in RESERVED_TUPLE_PROPERTY:
# Someone must investigate why. -yo property_holder.createAccessor(id)
#return accessor.__of__(self) # XXX - JPS: I have no idea if we should __of__ before returning
if isinstance(accessor, types.TupleType):
if id in RESERVED_TUPLE_PROPERTY:
return accessor
Base.aq_portal_type[aq_key].createAccessor(id)
accessor = getattr(property_holder, id, None) accessor = getattr(property_holder, id, None)
if accessor is not None: return accessor
return accessor except KeyError:
else: pass
return accessor
return None if id in ('portal_types', 'portal_url', 'portal_workflow'):
elif id in ('portal_types', 'portal_url', 'portal_workflow'):
# This is required to precent infinite loop (we need to access portal_types tool) # This is required to precent infinite loop (we need to access portal_types tool)
return None return None
......
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