Commit 98d5ec89 authored by Jean-Paul Smets's avatar Jean-Paul Smets

removed dangerous except in aq_dynamic


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3031 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c723bf87
...@@ -182,13 +182,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -182,13 +182,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
else: else:
prop_holder.security = ClassSecurityInfo() # Is this OK for security XXX ? prop_holder.security = ClassSecurityInfo() # Is this OK for security XXX ?
from Utils import initializeDefaultProperties from Utils import initializeDefaultProperties
#LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__)) initializeDefaultProperties([prop_holder], object=self)
try:
initializeDefaultProperties([prop_holder], object=self)
except:
LOG('Base', ERROR,
'Could not generate default properties on portal type %s.' % ptype,
error=sys.exc_info())
#LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__)) #LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__))
# We should now make sure workflow methods are defined # We should now make sure workflow methods are defined
# and also make sure simulation state is defined # and also make sure simulation state is defined
...@@ -196,81 +190,71 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -196,81 +190,71 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
#LOG('getWorkflowsFor', 0, str((self, [wf.id for wf in portal_workflow.getWorkflowsFor(self)]))) #LOG('getWorkflowsFor', 0, str((self, [wf.id for wf in portal_workflow.getWorkflowsFor(self)])))
for wf in portal_workflow.getWorkflowsFor(self): for wf in portal_workflow.getWorkflowsFor(self):
wf_id = wf.id wf_id = wf.id
try: #LOG('in aq_portal_type %s' % id, 0, "found state workflow %s" % wf.id)
#LOG('in aq_portal_type %s' % id, 0, "found state workflow %s" % wf.id) if wf.__class__.__name__ in ('DCWorkflowDefinition', ):
if wf.__class__.__name__ in ('DCWorkflowDefinition', ): # Create state var accessor
# Create state var accessor state_var = wf.variables.getStateVar()
state_var = wf.variables.getStateVar() method_id = 'get%s' % UpperCase(state_var)
method_id = 'get%s' % UpperCase(state_var) if not hasattr(prop_holder, method_id):
if not hasattr(prop_holder, method_id): method = WorkflowState.Getter(method_id, wf_id)
method = WorkflowState.Getter(method_id, wf_id) setattr(prop_holder, method_id, method) # Attach to portal_type
setattr(prop_holder, method_id, method) # Attach to portal_type prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id ) method_id = 'get%sTitle' % UpperCase(state_var)
method_id = 'get%sTitle' % UpperCase(state_var) if not hasattr(prop_holder, method_id):
if not hasattr(prop_holder, method_id): method = WorkflowState.TitleGetter(method_id, wf_id)
method = WorkflowState.TitleGetter(method_id, wf_id) setattr(prop_holder, method_id, method) # Attach to portal_type
setattr(prop_holder, method_id, method) # Attach to portal_type prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id ) #LOG('in aq_portal_type %s' % id, 0, "added state method %s" % method_id)
#LOG('in aq_portal_type %s' % id, 0, "added state method %s" % method_id) #LOG('in aq_portal_type %s' % id, 0, "found transition workflow %s" % wf.id)
except: if wf.__class__.__name__ in ('DCWorkflowDefinition', ):
LOG('Base', ERROR, for tr_id in wf.transitions.objectIds():
'Could not generate worklow state method for workflow %s on class %s.' % (wf_id, ptype), tdef = wf.transitions.get(tr_id, None)
error=sys.exc_info()) if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
try: method_id = convertToMixedCase(tr_id)
#LOG('in aq_portal_type %s' % id, 0, "found transition workflow %s" % wf.id) # We have to make a difference between a method which is on
if wf.__class__.__name__ in ('DCWorkflowDefinition', ): # the prop_holder or on the klass, if the method is on the
for tr_id in wf.transitions.objectIds(): # klass, then the WorkflowMethod created also need to be on the klass
tdef = wf.transitions.get(tr_id, None) if not hasattr(prop_holder, method_id) and not hasattr(klass,method_id):
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD: method = WorkflowMethod(klass._doNothing, tr_id)
method_id = convertToMixedCase(tr_id) setattr(prop_holder, method_id, method) # Attach to portal_type
# We have to make a difference between a method which is on prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
# the prop_holder or on the klass, if the method is on the #LOG('in aq_portal_type %s' % id, 0, "added transition method %s" % method_id)
# klass, then the WorkflowMethod created also need to be on the klass else:
# Wrap method into WorkflowMethod is needed
if getattr(klass,method_id,None) is not None:
method = getattr(klass, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
setattr(klass, method_id, WorkflowMethod(method, method_id))
else:
method = getattr(prop_holder, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
setattr(prop_holder, method_id, WorkflowMethod(method, method_id))
elif wf.__class__.__name__ in ('InteractionWorkflowDefinition', ):
for tr_id in wf.interactions.objectIds():
tdef = wf.interactions.get(tr_id, None)
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
for imethod_id in tdef.method_id:
method_id = imethod_id
if not hasattr(prop_holder, method_id) and not hasattr(klass,method_id): if not hasattr(prop_holder, method_id) and not hasattr(klass,method_id):
method = WorkflowMethod(klass._doNothing, tr_id) method = WorkflowMethod(klass._doNothing, imethod_id)
setattr(prop_holder, method_id, method) # Attach to portal_type setattr(prop_holder, method_id, method) # Attach to portal_type
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id ) prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
#LOG('in aq_portal_type %s' % id, 0, "added transition method %s" % method_id)
else: else:
# Wrap method into WorkflowMethod is needed # Wrap method into WorkflowMethod is needed
if getattr(klass,method_id,None) is not None: if getattr(klass,method_id,None) is not None:
method = getattr(klass, method_id) method = getattr(klass, method_id)
if callable(method): if callable(method):
if not isinstance(method, WorkflowMethod): if not isinstance(method, WorkflowMethod):
setattr(klass, method_id, WorkflowMethod(method, method_id)) method = WorkflowMethod(method, method_id)
setattr(klass, method_id, method)
else: else:
method = getattr(prop_holder, method_id) method = getattr(prop_holder, method_id)
if callable(method): if callable(method):
if not isinstance(method, WorkflowMethod): if not isinstance(method, WorkflowMethod):
setattr(prop_holder, method_id, WorkflowMethod(method, method_id)) method = WorkflowMethod(method, method_id)
elif wf.__class__.__name__ in ('InteractionWorkflowDefinition', ): setattr(prop_holder, method_id, method)
for tr_id in wf.interactions.objectIds():
tdef = wf.interactions.get(tr_id, None)
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
for imethod_id in tdef.method_id:
method_id = imethod_id
if not hasattr(prop_holder, method_id) and not hasattr(klass,method_id):
method = WorkflowMethod(klass._doNothing, imethod_id)
setattr(prop_holder, method_id, method) # Attach to portal_type
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
else:
# Wrap method into WorkflowMethod is needed
if getattr(klass,method_id,None) is not None:
method = getattr(klass, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
setattr(klass, method_id, method)
else:
method = getattr(prop_holder, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
setattr(prop_holder, method_id, method)
except:
LOG('Base', ERROR,
'Could not generate worklow transition methods for workflow %s on class %s.' % (wf_id, klass),
error=sys.exc_info())
# We can now associate it # We can now associate it
Base.aq_portal_type[ptype] = prop_holder Base.aq_portal_type[ptype] = prop_holder
...@@ -368,19 +352,12 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -368,19 +352,12 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
# Generate class methods # Generate class methods
if not Base.aq_method_generated.has_key(klass): if not Base.aq_method_generated.has_key(klass):
try: initializeClassDynamicProperties(self, klass)
initializeClassDynamicProperties(self, klass)
except:
LOG('_aq_dynamic',0,'error in initializeClassDynamicProperties', error=sys.exc_info())
generated = 1 generated = 1
# Generate portal_type methods # Generate portal_type methods
if not Base.aq_portal_type.has_key(ptype): if not Base.aq_portal_type.has_key(ptype):
try: initializePortalTypeDynamicProperties(self, klass, ptype)
initializePortalTypeDynamicProperties(self, klass, ptype)
#LOG('_aq_dynamic for %s' % ptype,0, aq_portal_type[ptype].__dict__.keys())
except:
LOG('_aq_dynamic',0,'error in initializePortalTypeDynamicProperties', error=sys.exc_info())
generated = 1 generated = 1
# Generate Related Accessors # Generate Related Accessors
...@@ -967,6 +944,13 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -967,6 +944,13 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
""" """
return self return self
def getDocumentInstance(self):
"""
Returns self
Returns instance if catehory throughdocument_instance relation
"""
return self
security.declareProtected( Permissions.AccessContentsInformation, 'asParentSqlExpression' ) security.declareProtected( Permissions.AccessContentsInformation, 'asParentSqlExpression' )
def getParentSqlExpression(self, table = 'catalog', strict_membership = 0): def getParentSqlExpression(self, table = 'catalog', strict_membership = 0):
""" """
......
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