Commit 8d4c2a58 authored by Jean-Paul Smets's avatar Jean-Paul Smets

This megapatch changes the way accessors are generated. Instead of generating...

This megapatch changes the way accessors are generated. Instead of generating all accessors for each portal type, we only generate tuples which are put in a kind of tuple cache. The idea is to minimise the number of objects which are created and use objects which are as small as possible. Then, the next time aq_dynamic is invoked, we dynamically create a new accessor instance based on the parameters provided in the tuple. This way, it is possible to reduce the memory footprint of ERP5 by 200 MB at least and create only those accessors which are needed. 
In addition, accessors are now generated per portal_type and per class. This way, if the class of a portal type changes in a system, different accessors are generated and there is no risk of falling into a problem of "first argument of method XXX must be of type YYY".
The downside is currently a possible speed decrease of 2-3%.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17606 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f22b5a0e
......@@ -18,6 +18,7 @@
import Globals
import App
from types import StringTypes
from AccessControl import getSecurityManager, ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
......@@ -195,24 +196,29 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
return
security.declarePrivate('notifyWorkflowMethod')
def notifyWorkflowMethod(self, ob, action, args=None, kw=None, transition_list=None):
def notifyWorkflowMethod(self, ob, transition_list, args=None, kw=None):
"""
InteractionWorkflow is stateless. Thus, this function should do nothing.
"""
return
security.declarePrivate('notifyBefore')
def notifyBefore(self, ob, action, args=None, kw=None, transition_list=None):
def notifyBefore(self, ob, transition_list, args=None, kw=None):
'''
Notifies this workflow of an action before it happens,
allowing veto by exception. Unless an exception is thrown, either
a notifySuccess() or notifyException() can be expected later on.
The action usually corresponds to a method name.
'''
if not transition_list: return
if type(transition_list) in StringTypes:
return
# Wrap args into kw since this is the only way
# to be compatible with DCWorkflow
# A better approach consists in extending DCWorkflow
if kw is None:
kw = {'workflow_method_args' : args}
else:
kw = kw.copy()
kw['workflow_method_args'] = args
filtered_transition_list = []
......@@ -236,11 +242,12 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
return filtered_transition_list
security.declarePrivate('notifySuccess')
def notifySuccess(self, ob, action, result, args=None, kw=None, transition_list=None):
def notifySuccess(self, ob, transition_list, result, args=None, kw=None):
'''
Notifies this workflow that an action has taken place.
'''
if not transition_list: return
if type(transition_list) in StringTypes:
return
kw = kw.copy()
kw['workflow_method_args'] = args
......
......@@ -43,8 +43,8 @@ class Reindex(Method):
# This is required to call the method form the Web
# More information at http://www.zope.org/Members/htrd/howto/FunctionTemplate
func_code = func_code()
func_code.co_varnames = ('self',)
func_code.co_argcount = 1
func_code.co_varnames = ('self', 'value') # XXX - This part should be configurable at instanciation
func_code.co_argcount = 2
func_defaults = ()
def __init__(self, id, accessor_id):
......@@ -75,6 +75,7 @@ class Dummy(Reindex):
self._id = id
self.__name__ = id
self._accessor_id = accessor_id
self.func_code = getattr(instance, self._accessor_id).func_code
def __call__(self, instance, *args, **kw):
method = getattr(instance, self._accessor_id)
......
......@@ -51,11 +51,11 @@ class Setter(Method):
# This is required to call the method form the Web
# More information at http://www.zope.org/Members/htrd/howto/FunctionTemplate
func_code = func_code()
func_code.co_varnames = ('self','value')
func_code.co_varnames = ('self', 'value')
func_code.co_argcount = 2
func_defaults = ()
def __init__(self, id, key, property_type, reindex=1, storage_id=None):
def __init__(self, id, key, property_type, storage_id=None, reindex=1):
self._id = id
self.__name__ = id
self._key = key
......
......@@ -51,7 +51,7 @@ class DefaultSetter(Method):
func_code.co_argcount = 2
func_defaults = ()
def __init__(self, id, key, property_type, reindex=1, storage_id=None):
def __init__(self, id, key, property_type, storage_id=None, reindex=1):
self._id = id
self.__name__ = id
self._key = key
......@@ -140,7 +140,7 @@ class SetSetter(Method):
func_code.co_argcount = 2
func_defaults = ()
def __init__(self, id, key, property_type, reindex=1, storage_id=None):
def __init__(self, id, key, property_type, storage_id=None, reindex=1):
self._id = id
self.__name__ = id
self._key = key
......@@ -227,6 +227,10 @@ class DefaultGetter(Method):
default = args[0]
else:
default = self._default
if default and len(default):
default = default[0]
else:
default = None
list_value = getattr(instance, self._storage_id, None)
if list_value is not None:
if self._is_tales_type:
......@@ -284,7 +288,9 @@ class ListGetter(Method):
else:
return list_value
return list(list_value)
return default
if default is None:
return None # nothing was defined as default so None is the right value
return list(default) # Make sure we return a list rather than a tuple
psyco.bind(__call__)
......
......@@ -29,6 +29,7 @@
from struct import unpack
from copy import copy
import warnings
import types
from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
......@@ -82,7 +83,7 @@ from pprint import pformat
from ZODB.POSException import ConflictError
from zLOG import LOG, INFO, ERROR, WARNING
_MARKER=[]
_MARKER = []
global registered_workflow_method_set
wildcard_interaction_method_id_matcher = re.compile(".*[\+\*].*")
......@@ -97,19 +98,32 @@ def resetRegisteredWorkflowMethod(portal_type=None):
class WorkflowMethod(Method):
def __init__(self, method, id=None, reindex=1, interaction_id=None):
def __init__(self, method, id=None, reindex=1):
"""
method - a callable object or a method
id - the workflow transition id. This is useful
to emulate "old" CMF behaviour but is
somehow inconsistent with the new registration based
approach implemented here.
We store id as _transition_id and use it
to register the transition for each portal
type and each workflow for which it is
applicable.
"""
self._m = method
if id is None:
id = method.__name__
self._id = id
self._interaction_id = interaction_id
self._transition_id = method.__name__
else:
self._transition_id = id
# Only publishable methods can be published as interactions
# A pure private method (ex. _doNothing) can not be published
# This is intentional to prevent methods such as submit, share to
# be called from a URL. If someone can show that this way
# is wrong (ex. for remote operation of a site), let us know.
if not method.__name__.startswith('_'):
self.__name__ = id
self.__name__ = method.__name__
for func_id in ['func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']:
setattr(self, func_id, getattr(method, func_id, None))
self._invoke_once = {}
......@@ -117,21 +131,21 @@ class WorkflowMethod(Method):
# invoke wrapWorkflowMethod at every call
# during the same transaction
def _setId(self, id) :
self._id = id
def getTransitionId(self):
return self._transition_id
def __call__(self, instance, *args, **kw):
"""
Invoke the wrapped method, and deal with the results.
"""
if self._id in ('getPhysicalPath', 'getId'):
if getattr(self, '__name__', None) in ('getPhysicalPath', 'getId'):
# To prevent infinite recursion, 2 methods must have special treatment
# this is clearly not the best way to implement this but it is
# already better than what we had. I (JPS) would prefer to use
# critical sections in this part of the code and a
# thread variable which tells in which semantic context the code
# should ne executed. - XXX
return self._m(instance, *args, **kw)
return self_m(instance, *args, **kw)
# New implementation does not use any longer wrapWorkflowMethod
# but directly calls the workflow methods
......@@ -166,7 +180,7 @@ class WorkflowMethod(Method):
candidate_transition_item_list = valid_invoke_once_item_list + \
self._invoke_always.get(portal_type, {}).items()
#LOG('candidate_transition_item_list %s' % self._id, 0, str(candidate_transition_item_list))
#LOG('candidate_transition_item_list %s' % self.__name__, 0, str(candidate_transition_item_list))
# Try to return immediately if there are no transition to invoke
if not candidate_transition_item_list:
......@@ -186,11 +200,11 @@ class WorkflowMethod(Method):
if valid_list:
valid_transition_item_list.append((wf_id, valid_list))
#LOG('valid_transition_item_list %s' % self._id, 0, str(valid_transition_item_list))
#LOG('valid_transition_item_list %s' % self.__name__, 0, str(valid_transition_item_list))
# Call whatever must be called before changing states
for wf_id, transition_list in valid_transition_item_list:
wf[wf_id].notifyBefore(instance, self._id, args=args, kw=kw, transition_list=transition_list)
wf[wf_id].notifyBefore(instance, transition_list, args=args, kw=kw)
# Compute expected result
result = apply(self.__dict__['_m'], (instance,) + args, kw)
......@@ -198,7 +212,7 @@ class WorkflowMethod(Method):
# Change the state of statefull workflows
for wf_id, transition_list in valid_transition_item_list:
try:
wf[wf_id].notifyWorkflowMethod(instance, self._id, args=args, kw=kw, transition_list=transition_list)
wf[wf_id].notifyWorkflowMethod(instance, transition_list, args=args, kw=kw)
except ObjectDeleted:
# Re-raise with a different result.
raise ObjectDeleted(result)
......@@ -208,7 +222,7 @@ class WorkflowMethod(Method):
# Call whatever must be called after changing states
for wf_id, transition_list in valid_transition_item_list:
wf[wf_id].notifySuccess(instance, self._id, result, args=args, kw=kw, transition_list=transition_list)
wf[wf_id].notifySuccess(instance, transition_list, result, args=args, kw=kw)
# Return result finally
return result
......@@ -234,7 +248,6 @@ class WorkflowMethod(Method):
"""
Registers the method so that _aq_reset may later reset it
"""
global registered_workflow_method_set
workflow_method_registry.append(self)
def reset(self, portal_type=None):
......@@ -248,19 +261,6 @@ class WorkflowMethod(Method):
self._invoke_once = {}
self._invoke_always = {}
class ActionMethod(Method):
def __init__(self, method, action_id, reindex=1):
self._m = method
self._id = action_id
def __call__(self, instance, *args, **kw):
"""
Invoke the wrapped method, and deal with the results.
"""
wf = getToolByName(instance, 'portal_workflow', None)
return wf.doActionFor(instance, self._id)
def _aq_reset():
Base.aq_method_generated = {}
Base.aq_portal_type = {}
......@@ -274,20 +274,155 @@ def _aq_reset():
# Reset workflow methods so that they no longer invoke workflows
resetRegisteredWorkflowMethod()
global method_registration_cache
method_registration_cache = {}
WORKFLOW_METHOD_MARKER = ('Base._doNothing',)
RESERVED_TUPLE_PROPERTY = ('_constraints', '_properties', '_categories',
'__implements__', 'property_sheets', '_erp5_properties' )
# It might be necessary to use another type for those reserved properties
# ex. list type
class PropertyHolder:
isRADContent = 1
def __init__(self):
self.__name__ = 'PropertyHolder'
self.security = ClassSecurityInfo() # We create a new security info object
self.workflow_method_registry = {}
def _getItemList(self):
return self.__dict__.items()
return filter(lambda x: x[0] not in RESERVED_TUPLE_PROPERTY,
self.__dict__.items())
# Accessor generation
def createAccessor(self, id):
"""
Invokes appropriate factory and create an accessor
"""
fake_accessor = getattr(self, id)
ptype = self._portal_type
if fake_accessor is WORKFLOW_METHOD_MARKER:
# Case 1 : a workflow method only
accessor = Base._doNothing
else:
# Case 2 : a workflow method over an accessor
#LOG('createAccessor', 0, "%s %s %s" % (ptype, id, fake_accessor))
(accessor_class, accessor_args, key) = fake_accessor
accessor = accessor_class(id, key, *accessor_args)
#permission = getattr(self, '%s__roles__' % id, None)
#if permission is not None:
#LOG('Found security declaration', 0, id)
#accessor.__roles__ = permission.__of__(self)
#LOG('Found security declaration2', 0, repr(permission.__of__(self)))
for wf_id, tr_id, once in self.workflow_method_registry.get(id, ()):
if not isinstance(accessor, WorkflowMethod):
#LOG('createWorkflowMethod', 0, "%s %s %s %s" % (ptype, id, wf_id, tr_id))
accessor = WorkflowMethod(accessor)
if once:
accessor.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
else:
accessor.registerTransitionAlways(ptype, wf_id, tr_id)
else:
#LOG('registerTransition', 0, "%s %s %s %s" % (ptype, id, wf_id, tr_id))
if once:
accessor.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
else:
accessor.registerTransitionAlways(ptype, wf_id, tr_id)
setattr(self, id, accessor)
def registerAccessor(self, id, key, accessor_class, accessor_args):
"""
Saves in a dictionary all parameters required to create an accessor
The goal here is to minimize memory occupation. We have found the following:
- the size of a tuple with simple types and the size
of None are the same (a pointer)
- the size of a pointer to a class is the same as the
size of None
- the python caching system for tuples is efficient for tuples
which contain simple types (string, int, etc.) but innefficient
for tuples which contain a pointer
- as a result, it is better to create separate dicts if
values contain pointers and single dict if value is
a tuple of simple types
Parameters:
id -- The id the accessor (ex. getFirstName)
key -- The id of the property (ex. first_name) or the id of the
method for Alias accessors
"""
#LOG('registerAccessor', 0, "%s %s %s" % (id , self._portal_type, accessor_args))
# First we try to compress the information required
# to build a new accessor in such way that
# if the same information is provided twice, we
# shall keep it once only
new_accessor_args = []
for arg in accessor_args:
if type(arg) is types.ListType:
new_accessor_args.append(tuple(arg))
else:
new_accessor_args.append(arg)
accessor_args = tuple(new_accessor_args)
original_registration_tuple = (accessor_class, accessor_args, key)
registration_tuple = method_registration_cache.get(original_registration_tuple)
if registration_tuple is None:
registration_tuple = original_registration_tuple
method_registration_cache[registration_tuple] = registration_tuple
# Use the cached tuple (same value, different pointer)
setattr(self, id, registration_tuple)
def registerWorkflowMethod(self, id, wf_id, tr_id, once_per_transaction=0):
#LOG('registerWorkflowMethod', 0, "%s %s %s %s %s" % (self._portal_type, id, wf_id, tr_id, once_per_transaction))
signature = (wf_id, tr_id, once_per_transaction)
signature_list = self.workflow_method_registry.get(id, ())
if signature not in signature_list:
self.workflow_method_registry[id] = signature_list + (signature,)
if getattr(self, id, None) is None:
setattr(self, id, WORKFLOW_METHOD_MARKER)
def declareProtected(self, permission, accessor_name):
"""
It is possible to gain 30% of accessor RAM footprint
by postponing security declaration.
WARNING: we optimize size by not setting security if
it is the same as the default. This may be a bit
dangerous if classes use another default
security.
"""
if permission != Permissions.AccessContentsInformation:
self.security.declareProtected(permission, accessor_name)
# Inspection methods
def getAccessorMethodItemList(self):
"""
Return a list of tuple (id, method) for every accessor
"""
return filter(lambda x: isinstance(x[1], Accessor), self._getItemList())
for x, y in self._getItemList():
if isinstance(y, types.TupleType):
if len(y) == 0:
raise ValueError("problem at %s %s" % (self._portal_type, x))
result = []
#for x in self._getItemList():
#if isinstance(x[1], Accessor):
#result.append(x)
#elif isinstance(x[1], types.TupleType):
#LOG('isinstance', 0, str(x))
#if x[1] is not WORKFLOW_METHOD_MARKER and issubclass(x[1][0], Accessor):
#result.append(x)
#return result
return filter(lambda x: isinstance(x[1], Accessor) or
(isinstance(x[1], types.TupleType)
and x[1] is not WORKFLOW_METHOD_MARKER
and x[0] != '__ac_permissions__'
and issubclass(x[1][0], Accessor))
, self._getItemList())
def getAccessorMethodIdList(self):
"""
......@@ -299,7 +434,9 @@ class PropertyHolder:
"""
Return a list of tuple (id, method) for every workflow method
"""
return filter(lambda x: isinstance(x[1], WorkflowMethod), self._getItemList())
return filter(lambda x: isinstance(x[1], WorkflowMethod) or
(isinstance(x[1], types.TupleType)
and x[1] is WORKFLOW_METHOD_MARKER), self._getItemList())
def getWorkflowMethodIdList(self):
"""
......@@ -307,18 +444,6 @@ class PropertyHolder:
"""
return map(lambda x: x[0], self.getWorkflowMethodItemList())
def getActionMethodItemList(self):
"""
Return a list of tuple (id, method) for every workflow action method
"""
return filter(lambda x: isinstance(x[1], ActionMethod), self._getItemList())
def getActionMethodIdList(self):
"""
Return the list of workflow action method IDs
"""
return map(lambda x: x[0], self.getActionMethodItemList())
def _getClassDict(self, klass, inherited=1, local=1):
"""
Return a dict for every property of a class
......@@ -341,7 +466,7 @@ class PropertyHolder:
def getClassMethodItemList(self, klass, inherited=1, local=1):
"""
Return a list of tuple (id, method) for every class method
Return a list of tuple (id, method, module) for every class method
"""
return filter(lambda x: callable(x[1]) and not isinstance(x[1], Method),
self._getClassItemList(klass, inherited=inherited, local=local))
......@@ -380,22 +505,22 @@ def initializeClassDynamicProperties(self, klass):
if getattr(super_klass, 'isRADContent', 0):
initializeClassDynamicProperties(self, super_klass)
# Initialize default properties
from Utils import initializeDefaultProperties
from Utils import setDefaultClassProperties
if not getattr(klass, 'isPortalContent', None):
initializeDefaultProperties([klass], object=self)
if getattr(klass, 'isRADContent', 0):
setDefaultClassProperties(klass)
# Mark as generated
Base.aq_method_generated[klass] = 1
def initializePortalTypeDynamicProperties(self, klass, ptype):
def initializePortalTypeDynamicProperties(self, klass, ptype, aq_key):
## Init CachingMethod which implements caching for ERP5
from Products.ERP5Type.Cache import initializePortalCachingProperties
initializePortalCachingProperties(self)
id = ''
#LOG('before aq_portal_type %s' % id, 0, str(ptype))
if ptype not in Base.aq_portal_type:
if aq_key not in Base.aq_portal_type:
# Mark as generated
#prop_holder = Base.aq_portal_type[ptype] = PropertyHolder()
prop_holder = PropertyHolder()
# Recurse to parent object
parent_object = self.aq_inner.aq_parent
......@@ -405,12 +530,12 @@ def initializePortalTypeDynamicProperties(self, klass, ptype):
(ptype != parent_type or klass != parent_klass) and \
not Base.aq_portal_type.has_key(parent_type):
initializePortalTypeDynamicProperties(parent_object, parent_klass,
parent_type)
parent_type, parent_object._aq_key())
# Initiatise portal_type properties (XXX)
ptype_object = getattr(aq_base(self.portal_types), ptype, None)
cat_list = []
prop_list = list(getattr(klass, '_properties', []))
constraint_list = []
cat_list = list(getattr(klass, '_categories', []))
constraint_list = list(getattr(klass, '_constraints', []))
if (ptype_object is not None) and \
(ptype_object.meta_type == 'ERP5 Type Information'):
# Make sure this is an ERP5Type object
......@@ -443,12 +568,13 @@ def initializePortalTypeDynamicProperties(self, klass, ptype):
if (ptype_object is not None) and \
(ptype_object.meta_type == 'ERP5 Type Information'):
cat_list += ptype_object.base_category_list
prop_holder._portal_type = ptype
prop_holder._properties = prop_list
prop_holder._categories = cat_list
prop_holder._constraints = constraint_list
prop_holder.security = ClassSecurityInfo() # We create a new security info object
from Utils import initializeDefaultProperties
initializeDefaultProperties([prop_holder], object=self)
from Utils import setDefaultClassProperties, setDefaultProperties
setDefaultClassProperties(prop_holder)
setDefaultProperties(prop_holder, object=self)
#LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__))
# initializePortalTypeDynamicWorkflowMethods(self,
initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder)
......@@ -458,7 +584,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype):
# For now, this line below is commented, because this breaks
# _aq_dynamic without JP's patch to Zope for an unknown reason.
#klass.__ac_permissions__ = prop_holder.__ac_permissions__
Base.aq_portal_type[ptype] = prop_holder
Base.aq_portal_type[aq_key] = prop_holder
def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder):
"""We should now make sure workflow methods are defined
......@@ -492,76 +618,34 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder):
for wf in portal_workflow.getWorkflowsFor(self):
wf_id = wf.id
if wf.__class__.__name__ in ('DCWorkflowDefinition', ):
for tr_id in wf.transitions.objectIds():
interaction_id_list = wf.transitions.objectIds()
for tr_id in interaction_id_list:
tdef = wf.transitions.get(tr_id, None)
if tdef.trigger_type == TRIGGER_USER_ACTION:
method_id = convertToMixedCase(tr_id)
# We have to make a difference between a method which is on
# the prop_holder or on the klass, if the method is on the
# klass, then the WorkflowMethod created also need to be on the klass
if (not hasattr(prop_holder, method_id)) and \
(not hasattr(klass, method_id)):
method = ActionMethod(klass._doNothing, tr_id)
# Attach to portal_type
setattr(prop_holder, method_id, method)
prop_holder.security.declareProtected(
Permissions.AccessContentsInformation,
method_id )
else:
# Wrap method into WorkflowMethod is needed
try:
method = getattr(klass, method_id)
except AttributeError:
method = getattr(prop_holder, method_id)
work_method_holder = prop_holder
else:
work_method_holder = klass
LOG('initializePortalTypeDynamicWorkflowMethods', 100,
'WARNING! Can not initialize %s on %s due to existing %s' % \
(method_id, str(work_method_holder), method))
elif tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
method_id = convertToMixedCase(tr_id)
# We have to make a difference between a method which is on
# the prop_holder or on the klass, if the method is on the
# klass, then the WorkflowMethod created also need to be on the klass
if (not hasattr(prop_holder, method_id)) and \
(not hasattr(klass, method_id)):
method = WorkflowMethod(klass._doNothing, tr_id)
method.registerTransitionAlways(ptype, wf_id, tr_id)
# Attach to portal_type
setattr(prop_holder, method_id, method)
prop_holder.security.declareProtected(
Permissions.AccessContentsInformation,
method_id )
else:
# Wrap method into WorkflowMethod is needed
try:
if getattr(klass, method_id, _MARKER) is not _MARKER:
method = getattr(klass, method_id)
except AttributeError:
method = getattr(prop_holder, method_id)
work_method_holder = prop_holder
else:
work_method_holder = klass
# Wrap method
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
method.registerTransitionAlways(ptype, wf_id, tr_id)
setattr(work_method_holder, method_id, method)
else :
# some methods (eg. set_ready) don't have the same name
# (setReady) as the workflow transition (set_ready).
# If they are associated with both an InteractionWorkflow
# and a DCWorkflow, and the WorkflowMethod is created for
# the InterractionWorkflow, then it may be associated with
# a wrong transition name (setReady).
# Here we force it's id to be the transition name (set_ready).
method._setId(tr_id)
method = WorkflowMethod(method)
setattr(klass, method_id, method)
else:
# We must be sure that we
# are going to register class defined
# workflow methods to the appropriate transition
transition_id = method.getTransitionId()
if transition_id in interaction_id_list:
method.registerTransitionAlways(ptype, wf_id, transition_id)
method.registerTransitionAlways(ptype, wf_id, tr_id)
else:
LOG('initializePortalTypeDynamicWorkflowMethods', 100,
'WARNING! Can not initialize %s on %s' % \
(method_id, str(work_method_holder)))
else:
prop_holder.security.declareProtected(Permissions.AccessContentsInformation,
method_id)
prop_holder.registerWorkflowMethod(method_id, wf_id, tr_id)
# XXX This part is (more or less...) a copy and paste
# We need to run this part twice in order to handle interactions of interactions
# ex. an interaction workflow creates a workflow method which matches
......@@ -569,7 +653,8 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder):
for wf in portal_workflow.getWorkflowsFor(self) * 2: # This is really necesary
wf_id = wf.id
if wf.__class__.__name__ in ('InteractionWorkflowDefinition', ):
for tr_id in wf.interactions.objectIds():
interaction_id_list = wf.interactions.objectIds()
for tr_id in interaction_id_list:
tdef = wf.interactions.get(tr_id, None)
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
# XXX Prefiltering per portal type would be more efficient
......@@ -585,53 +670,33 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder):
# Single method
method_id_list = [imethod_id]
for method_id in method_id_list:
if (not hasattr(prop_holder, method_id)) and \
(not hasattr(klass,method_id)):
method = WorkflowMethod(klass._doNothing, imethod_id)
if not tdef.once_per_transaction:
method.registerTransitionAlways(ptype, wf_id, tr_id)
else:
method.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
# Attach to portal_type
setattr(prop_holder, method_id, method)
prop_holder.security.declareProtected(
Permissions.AccessContentsInformation,
method_id)
else:
# Wrap method into WorkflowMethod is needed
if getattr(klass, method_id, None) is not None:
if getattr(klass, method_id, _MARKER) is not _MARKER:
method = getattr(klass, method_id)
# Wrap method
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
if not tdef.once_per_transaction:
method.registerTransitionAlways(ptype, wf_id, tr_id)
else:
method.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
# We must set the method on the klass
# because klass has priority in lookup over
# _ac_dynamic
method = WorkflowMethod(method)
setattr(klass, method_id, method)
else:
if not tdef.once_per_transaction:
method.registerTransitionAlways(ptype, wf_id, tr_id)
else:
# We must be sure that we
# are going to register class defined
# workflow methods to the appropriate transition
transition_id = method.getTransitionId()
if transition_id in interaction_id_list:
method.registerTransitionAlways(ptype, wf_id, transition_id)
if tdef.once_per_transaction:
method.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
else:
method = getattr(prop_holder, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
if not tdef.once_per_transaction:
method.registerTransitionAlways(ptype, wf_id, tr_id)
else:
method.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
setattr(prop_holder, method_id, method)
else:
if not tdef.once_per_transaction:
method.registerTransitionAlways(ptype, wf_id, tr_id)
LOG('initializePortalTypeDynamicWorkflowMethods', 100,
'WARNING! Can not initialize %s on %s' % \
(method_id, str(work_method_holder)))
else:
method.registerTransitionOncePerTransaction(ptype, wf_id, tr_id)
prop_holder.security.declareProtected(Permissions.AccessContentsInformation,
method_id)
prop_holder.registerWorkflowMethod(method_id, wf_id, tr_id,
tdef.once_per_transaction)
class Base( CopyContainer,
PortalContent,
......@@ -711,22 +776,27 @@ class Base( CopyContainer,
"""
initializeClassDynamicProperties(self, self.__class__)
def _aq_key(self):
return (self.portal_type, self.__class__)
def _propertyMap(self):
""" Method overload - properties are now defined on the ptype """
ptype = self.portal_type
aq_key = self._aq_key()
self._aq_dynamic('id') # Make sure aq_dynamic has been called once
if Base.aq_portal_type.has_key(ptype):
return tuple(list(getattr(Base.aq_portal_type[ptype], '_properties', ())) +
if Base.aq_portal_type.has_key(aq_key):
return tuple(list(getattr(Base.aq_portal_type[aq_key], '_properties', ())) +
list(getattr(self, '_local_properties', ())))
return ERP5PropertyManager._propertyMap(self)
def _aq_dynamic_pmethod(self, id):
ptype = self.portal_type
klass = self.__class__
aq_key = (ptype, klass) # We do not use _aq_key() here for speed
#LOG("In _aq_dynamic_pmethod", 0, str((id, ptype, self)))
if Base.aq_portal_type.has_key(ptype):
return getattr(Base.aq_portal_type[ptype], id, None).__of__(self)
if Base.aq_portal_type.has_key(aq_key):
return getattr(Base.aq_portal_type[aq_key], id, None).__of__(self)
return None
......@@ -738,22 +808,49 @@ class Base( CopyContainer,
pformat(rev1.__dict__),
pformat(rev2.__dict__)))
def initializePortalTypeDynamicProperties(self):
"""
Test purpose
"""
ptype = self.portal_type
klass = self.__class__
aq_key = (ptype, klass) # We do not use _aq_key() here for speed
initializePortalTypeDynamicProperties(self, klass, ptype, aq_key)
from Products.ERP5Form.PreferenceTool import createPreferenceToolAccessorList
createPreferenceToolAccessorList(self.getPortalObject())
def _aq_dynamic(self, id):
# _aq_dynamic has been created so that callable objects
# and default properties can be associated per portal type
# and per class. Other uses are possible (ex. WebSection).
ptype = self.portal_type
klass = self.__class__
aq_key = (ptype, klass) # We do not use _aq_key() here for speed
# If this is a portal_type property and everything is already defined
# for that portal_type, try to return a value ASAP
try:
return getattr(Base.aq_portal_type[ptype], id, None)
except KeyError:
if id.startswith('portal_'):
if aq_key in Base.aq_portal_type:
property_holder = Base.aq_portal_type[aq_key]
accessor = getattr(property_holder, id, None)
if accessor is not None:
# Clearly this below has a bad effect in CMFCategory.
# Someone must investigate why. -yo
#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)
if accessor is not None:
return accessor
else:
return accessor
return None
elif id in ('portal_types', 'portal_url', 'portal_workflow'):
# This is required to precent infinite loop (we need to access portal_types tool)
return None
# Proceed with property generation
klass = self.__class__
if self.isTempObject():
# If self is a temporary object, generate methods for the base
# document class rather than for the temporary document class.
......@@ -769,12 +866,12 @@ class Base( CopyContainer,
generated = 1
# Generate portal_type methods
if not Base.aq_portal_type.has_key(ptype):
if not Base.aq_portal_type.has_key(aq_key):
if ptype == 'Preference':
# XXX-JPS this should be moved to Preference class
from Products.ERP5Form.PreferenceTool import updatePreferenceClassPropertySheetList
updatePreferenceClassPropertySheetList()
initializePortalTypeDynamicProperties(self, klass, ptype)
initializePortalTypeDynamicProperties(self, klass, ptype, aq_key)
generated = 1
# Generate Related Accessors
......@@ -799,12 +896,12 @@ class Base( CopyContainer,
for bid in base_category_list:
if bid not in generated_bid:
#LOG( "Create createRelatedValueAccessors %s" % bid,0,'')
createRelatedValueAccessors(Base, bid)
createRelatedValueAccessors(bid)
generated_bid[bid] = 1
for ptype in portal_types.objectValues('ERP5 Type Information') :
for bid in ptype.base_category_list :
if bid not in generated_bid :
createRelatedValueAccessors(Base, bid)
createRelatedValueAccessors(bid)
generated_bid[bid] = 1
Base.aq_related_generated = 1
......@@ -1155,12 +1252,13 @@ class Base( CopyContainer,
pass
return method(**kw)
# Try to get a portal_type property (Implementation Dependent)
if not Base.aq_portal_type.has_key(self.portal_type):
aq_key = self._aq_key()
if not Base.aq_portal_type.has_key(aq_key):
try:
self._aq_dynamic(accessor_name)
except AttributeError:
pass
if hasattr(Base.aq_portal_type[self.portal_type], accessor_name):
if hasattr(Base.aq_portal_type[aq_key], accessor_name):
method = getattr(self, accessor_name)
if d is not _MARKER:
try:
......@@ -1221,14 +1319,15 @@ class Base( CopyContainer,
method(value, **kw)
return
# Try to get a portal_type property (Implementation Dependent)
if not Base.aq_portal_type.has_key(self.portal_type):
aq_key = self._aq_key()
if not Base.aq_portal_type.has_key(aq_key):
self._aq_dynamic('id') # Make sure _aq_dynamic has been called once
if hasattr(Base.aq_portal_type[self.portal_type], accessor_name):
if hasattr(Base.aq_portal_type[aq_key], accessor_name):
method = getattr(self, accessor_name)
# LOG("Base.py", 0, "method = %s, name = %s" %(method, accessor_name))
method(value, **kw)
return
if hasattr(Base.aq_portal_type[self.portal_type], public_accessor_name):
if hasattr(Base.aq_portal_type[aq_key], public_accessor_name):
method = getattr(self, public_accessor_name)
method(value, **kw)
return
......@@ -1267,13 +1366,14 @@ class Base( CopyContainer,
method(value, **kw)
return
# Try to get a portal_type property (Implementation Dependent)
if not Base.aq_portal_type.has_key(self.portal_type):
aq_key = self._aq_key()
if not Base.aq_portal_type.has_key(aq_key):
self._aq_dynamic('id') # Make sure _aq_dynamic has been called once
if hasattr(Base.aq_portal_type[self.portal_type], accessor_name):
if hasattr(Base.aq_portal_type[aq_key], accessor_name):
method = getattr(self, accessor_name)
method(value, **kw)
return
if hasattr(Base.aq_portal_type[self.portal_type], public_accessor_name):
if hasattr(Base.aq_portal_type[aq_key], public_accessor_name):
method = getattr(self, public_accessor_name)
method(value, **kw)
return
......@@ -1347,7 +1447,7 @@ class Base( CopyContainer,
def ping(self):
pass
ping = WorkflowMethod( ping )
ping = WorkflowMethod(ping)
# Object attributes update method
security.declarePrivate( '_edit' )
......@@ -1462,6 +1562,24 @@ class Base( CopyContainer,
def getPropertyMap(self):
return self.propertyMap()
# ERP5 content properties interface
security.declareProtected( Permissions.View, 'getContentPropertyIdList' )
def getContentPropertyIdList(self):
"""
Return content properties of the current instance.
Content properties are filtered out in getPropertyIdList so
that rendering in ZMI is compatible with Zope standard properties
"""
return [property['id'] for property in self._erp5_properties if property['type'] == 'content']
security.declareProtected( Permissions.View, 'getStandardPropertyIdList' )
def getStandardPropertyIdList(self):
"""
Return standard properties of the current instance.
Unlike getPropertyIdList, properties are not converted or rewritten here.
"""
return [property['id'] for property in self._erp5_properties if property['type'] != 'content']
# Catalog Related
security.declareProtected( Permissions.View, 'getObject' )
def getObject(self, relative_url = None, REQUEST=None):
......@@ -2998,6 +3116,7 @@ class Base( CopyContainer,
A template is no longer indexable
TODO:
- make template read only, acquired local roles, etc.
- stronger security model
- prevent from changing templates or invoking workflows
"""
......@@ -3010,6 +3129,7 @@ class Base( CopyContainer,
catalog.unindexObject(self, uid=self.getUid())
self.isIndexable = 0
self.isTemplate = 1
# XXX reset security here
security.declareProtected(Permissions.ModifyPortalContent,'makeTemplateInstance')
def makeTemplateInstance(self):
......@@ -3058,7 +3178,7 @@ class Base( CopyContainer,
# Documentation Helpers
security.declareProtected( Permissions.ManagePortal, 'asDocumentationHelper' )
def asDocumentationHelper(self, item_id=None):
def asDocumentationHelper(self, item_id=None, REQUEST=None):
"""
Fills and return a DocHelper object from context.
Overload this in any object the has to fill the DocHelper in its own way.
......@@ -3102,8 +3222,12 @@ class Base( CopyContainer,
by property or category.
"""
# New implementation of DocumentationHelper (ongoing work)
# from DocumentationHelper import PortalTypeInstanceDocumentationHelper
# return PortalTypeInstanceDocumentationHelper(self.getRelativeUrl()).__of__(self)
if 0:
from DocumentationHelper import PortalTypeInstanceDocumentationHelper
helper = PortalTypeInstanceDocumentationHelper(self.getRelativeUrl()).__of__(self)
if REQUEST is not None:
return helper.view()
return helper
if item_id is None:
documented_item = self
......@@ -3169,7 +3293,8 @@ class Base( CopyContainer,
# PortalType-level methods
# XXX: accessing portal_type directly because accessors are not generated on instances
if getattr(documented_item, 'portal_type', None) is not None:
for k, v in Base.aq_portal_type[documented_item.portal_type].__dict__.items():
aq_key = documented_item._aq_key()
for k, v in Base.aq_portal_type[aq_key].__dict__.items():
if callable(v) and not (k.startswith('_base') or k.startswith('_category')):
subdochelper = newTempDocumentationHelper(dochelper, k,
title=k, description=inspect.getdoc(v),
......
......@@ -919,7 +919,7 @@ def initializeProduct( context,
klass_permission=klass.permission_type
#LOG("ContentInit", 0, str(content_constructors))
utils.ContentInit( klass.meta_type,
utils.ContentInit(klass.meta_type,
content_types=[klass],
permission=klass_permission,
extra_constructors=tuple(content_constructors),
......@@ -998,17 +998,6 @@ def setDefaultConstructor(klass):
document_constructor.__name__ = document_constructor_name
# Creation of default property accessors and values
def initializeDefaultProperties(property_holder_list, object=None):
"""
Creates class attributes with a default value.
"""
for property_holder in property_holder_list:
if getattr(property_holder, 'isRADContent', 0):
setDefaultClassProperties(property_holder)
setDefaultProperties(property_holder, object=object)
def createExpressionContext(object):
"""
Return a context used for evaluating a TALES expression.
......@@ -1140,6 +1129,9 @@ def setDefaultProperties(property_holder, object=None):
if isinstance(value, Expression):
const[key] = value(econtext)
# Store ERP5 properties on specific attributes
property_holder._erp5_properties = tuple(prop_list)
# Create default accessors for property sheets
converted_prop_list = []
converted_prop_keys = {}
......@@ -1299,8 +1291,8 @@ def setDefaultProperties(property_holder, object=None):
read_permission = Permissions.AccessContentsInformation
write_permission = Permissions.ModifyPortalContent
# Actualy create accessors
createRelatedValueAccessors(property_holder, cat,
read_permission=read_permission, write_permission=write_permission)
createRelatedValueAccessors(cat, read_permission=read_permission,
write_permission=write_permission)
# Unnecessary to create these accessors more than once.
base_category_dict.clear()
# Create the constraint method list - always check type
......@@ -1397,12 +1389,8 @@ def createDefaultAccessors(property_holder, id, prop = None,
# Create Getters
if prop.has_key('acquisition_base_category'):
# Create getters for an acquired property
# The base accessor returns the first item in a list
# and simulates a simple property
# XXXX Missing Boolean accessor
accessor_name = 'get' + UpperCase(id)
base_accessor = Acquired.DefaultGetter(accessor_name,
id,
accessor_args = (
prop['type'],
prop.get('default'),
prop['acquisition_base_category'],
......@@ -1411,81 +1399,61 @@ def createDefaultAccessors(property_holder, id, prop = None,
prop.get('acquisition_copy_value',0),
prop.get('acquisition_mask_value',0),
prop.get('acquisition_sync_value',0),
storage_id = prop.get('storage_id'),
alt_accessor_id = prop.get('alt_accessor_id'),
is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)),
is_tales_type = (prop['type'] == 'tales')
)
# The default accessor returns the first item in a list
default_accessor = base_accessor
# The list accessor returns the whole list
accessor_name = 'get' + UpperCase(id) + 'List'
list_accessor = Acquired.ListGetter(accessor_name,
id,
prop['type'],
prop.get('default'),
prop['acquisition_base_category'],
prop['acquisition_portal_type'],
prop['acquisition_accessor_id'],
prop.get('acquisition_copy_value',0),
prop.get('acquisition_mask_value',0),
prop.get('acquisition_sync_value',0),
storage_id = prop.get('storage_id'),
alt_accessor_id = prop.get('alt_accessor_id'),
is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)),
is_tales_type = (prop['type'] == 'tales')
prop.get('storage_id'),
prop.get('alt_accessor_id'),
(prop['type'] in list_types or prop.get('multivalued', 0)),
(prop['type'] == 'tales')
)
# Base Getter
accessor_name = 'get' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id)
base_accessor = base_accessor.dummy_copy(accessor_name)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
# Default Getter
accessor_name = 'getDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGetDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
# List Getter
accessor_name = 'get' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Acquired.ListGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Acquired.ListGetter, accessor_args)
if prop['type'] == 'content':
#LOG('Value Object Accessor', 0, prop['id'])
# Base Getter
accessor_name = 'get' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
# Default Getter
accessor_name = 'getDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGetDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Acquired.DefaultGetter, accessor_args)
# List Getter
accessor_name = 'get' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Acquired.ListGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Acquired.ListGetter, accessor_args)
# AcquiredProperty Getters
if prop.has_key('acquired_property_id'):
for aq_id in prop['acquired_property_id']:
......@@ -1494,8 +1462,7 @@ def createDefaultAccessors(property_holder, id, prop = None,
# print "Set composed_id accessor %s" % composed_id
accessor_name = 'get' + UpperCase(composed_id)
# print "Set accessor_name accessor %s" % accessor_name
base_accessor = AcquiredProperty.Getter(accessor_name,
composed_id,
accessor_args = (
prop['type'],
prop['portal_type'],
aq_id,
......@@ -1505,99 +1472,49 @@ def createDefaultAccessors(property_holder, id, prop = None,
prop.get('acquisition_copy_value',0),
prop.get('acquisition_mask_value',0),
prop.get('acquisition_sync_value',0),
storage_id = prop.get('storage_id'),
alt_accessor_id = prop.get('alt_accessor_id'),
is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)),
is_tales_type = (prop['type'] == 'tales')
prop.get('storage_id'),
prop.get('alt_accessor_id'),
(prop['type'] in list_types or prop.get('multivalued', 0)),
(prop['type'] == 'tales')
)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.Getter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.Getter, accessor_args)
# Default Getter
accessor_name = 'getDefault' + UpperCase(composed_id)
base_accessor = AcquiredProperty.DefaultGetter(accessor_name,
composed_id,
prop['type'],
prop['portal_type'],
aq_id,
prop['acquisition_base_category'],
prop['acquisition_portal_type'],
prop['acquisition_accessor_id'],
prop.get('acquisition_copy_value',0),
prop.get('acquisition_mask_value',0),
prop.get('acquisition_sync_value',0),
storage_id = prop.get('storage_id'),
alt_accessor_id = prop.get('alt_accessor_id'),
is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)),
is_tales_type = (prop['type'] == 'tales')
)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGetDefault' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.DefaultGetter, accessor_args)
# List Getter
################# NOT YET
# Setter
accessor_name = 'set' + UpperCase(composed_id)
base_accessor = AcquiredProperty.Setter(accessor_name,
composed_id,
prop['type'],
prop['portal_type'],
aq_id,
prop['acquisition_base_category'],
prop['acquisition_portal_type'],
prop['acquisition_accessor_id'],
prop.get('acquisition_copy_value',0),
prop.get('acquisition_mask_value',0),
prop.get('acquisition_sync_value',0),
storage_id = prop.get('storage_id'),
alt_accessor_id = prop.get('alt_accessor_id'),
is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)),
is_tales_type = (prop['type'] == 'tales'),
reindex = 1
)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name )
property_holder.registerAccessor(accessor_name, '_' + accessor_name, Alias.Reindex, ())
property_holder.declareProtected( write_permission, accessor_name )
accessor_name = '_set' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.Setter, accessor_args)
accessor_name = '_baseSet' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
# Default Getter
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.Setter, accessor_args)
# Default Setter
accessor_name = 'setDefault' + UpperCase(composed_id)
base_accessor = AcquiredProperty.DefaultSetter(accessor_name,
composed_id,
prop['type'],
prop['portal_type'],
aq_id,
prop['acquisition_base_category'],
prop['acquisition_portal_type'],
prop['acquisition_accessor_id'],
prop.get('acquisition_copy_value',0),
prop.get('acquisition_mask_value',0),
prop.get('acquisition_sync_value',0),
storage_id = prop.get('storage_id'),
alt_accessor_id = prop.get('alt_accessor_id'),
is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)),
is_tales_type = (prop['type'] == 'tales'),
reindex = 1
)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name )
property_holder.registerAccessor(accessor_name, '_' + accessor_name, Alias.Reindex, ())
property_holder.declareProtected( write_permission, accessor_name )
accessor_name = '_setDefault' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.DefaultSetter, accessor_args)
accessor_name = '_baseSetDefault' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, composed_id, AcquiredProperty.DefaultSetter, accessor_args)
# List Getter
################# NOT YET
......@@ -1606,238 +1523,176 @@ def createDefaultAccessors(property_holder, id, prop = None,
# and simulates a simple property
# The default value is the first element of prop.get('default') if it exists
default = prop.get('default')
try:
default = default[0]
except (TypeError, IndexError):
default = None
accessor_name = 'get' + UpperCase(id)
base_accessor = List.Getter(accessor_name, id, prop['type'], default = default,
storage_id = prop.get('storage_id'))
# The default accessor returns the first item in a list
accessor_name = 'getDefault' + UpperCase(id)
default_accessor = List.DefaultGetter(accessor_name, id, prop['type'], default = default,
storage_id = prop.get('storage_id'))
# The list accessor returns the whole list
accessor_name = 'get' + UpperCase(id) + 'List'
list_accessor = List.ListGetter(accessor_name, id, prop['type'],
default = prop.get('default'), storage_id = prop.get('storage_id'))
# The set accessor returns the whole list
accessor_name = 'get' + UpperCase(id) + 'Set'
set_accessor = List.SetGetter(accessor_name, id, prop['type'], default = prop.get('default'),
storage_id = prop.get('storage_id'))
accessor_args = (prop['type'], prop.get('default'), prop.get('storage_id'))
# Create getters for a list property
accessor_name = 'get' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, List.Getter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, List.Getter, accessor_args)
accessor_name = 'getDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, List.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGetDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, List.DefaultGetter, accessor_args)
accessor_name = 'get' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, List.ListGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, List.ListGetter, accessor_args)
accessor_name = 'get' + UpperCase(id) + 'Set'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, set_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, List.SetGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'Set'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, set_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, List.SetGetter, accessor_args)
elif prop['type'] == 'content':
# Create url getters for an object property
accessor_name = 'get' + UpperCase(id)
base_accessor = Content.Getter(accessor_name, id, prop['type'],
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
# The default accessor returns the first item in a list
accessor_name = 'getDefault' + UpperCase(id)
default_accessor = Content.DefaultGetter(accessor_name, id, prop['type'],
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
# The list accessor returns the whole list
accessor_name = 'get' + UpperCase(id) + 'List'
list_accessor = Content.ListGetter(accessor_name, id, prop['type'],
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
accessor_args = (prop['type'], prop.get('portal_type'), prop.get('storage_id'))
# Create getters for a list property
accessor_name = 'get' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Content.Getter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Content.Getter, accessor_args)
accessor_name = 'getDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Content.DefaultGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGetDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Content.DefaultGetter, accessor_args)
accessor_name = 'get' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Content.ListGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
# Create getters for an object property
accessor_name = 'get' + UpperCase(id) + 'Value'
base_accessor = Content.ValueGetter(accessor_name, id, prop['type'],
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
# The default accessor returns the first item in a list
accessor_name = 'getDefault' + UpperCase(id) + 'Value'
default_accessor = Content.DefaultValueGetter(accessor_name, id, prop['type'],
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
# The list accessor returns the whole list
accessor_name = 'get' + UpperCase(id) + 'ValueList'
list_accessor = Content.ValueListGetter(accessor_name, id, prop['type'],
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
property_holder.registerAccessor(accessor_name, id, Content.ListGetter, accessor_args)
# Create value getters for a list property
accessor_name = 'get' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Content.ValueGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Content.ValueGetter, accessor_args)
accessor_name = 'getDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Content.DefaultValueGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGetDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, default_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Content.DefaultValueGetter, accessor_args)
accessor_name = 'get' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Content.ValueListGetter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, list_accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Content.ValueListGetter, accessor_args)
if prop.has_key('acquired_property_id'):
for aq_id in prop['acquired_property_id']:
for composed_id in ("%s_%s" % (id, aq_id), "default_%s_%s" % (id, aq_id)) :
accessor_name = 'get' + UpperCase(composed_id)
base_accessor = ContentProperty.Getter(accessor_name, composed_id, prop['type'], aq_id,
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
accessor_args = (prop['type'], aq_id, prop.get('portal_type'), prop.get('storage_id'))
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, composed_id, ContentProperty.Getter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = 'get' + UpperCase(composed_id) + 'List'
base_accessor = ContentProperty.Getter(accessor_name, composed_id + '_list', prop['type'], aq_id + '_list',
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'))
list_accessor_args = (prop['type'], aq_id + '_list', prop.get('portal_type'), prop.get('storage_id'))
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, composed_id + '_list',
ContentProperty.Getter, list_accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
# No default getter YET XXXXXXXXXXXXXX
# No list getter YET XXXXXXXXXXXXXX
accessor_name = '_set' + UpperCase(composed_id)
base_accessor = ContentProperty.Setter(accessor_name, composed_id, prop['type'], aq_id,
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'), reindex=0)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( write_permission, accessor_name )
property_holder.registerAccessor(accessor_name, composed_id, ContentProperty.Setter, accessor_args)
property_holder.declareProtected( write_permission, accessor_name )
accessor_name = '_set' + UpperCase(composed_id) + 'List'
base_accessor = ContentProperty.Setter(accessor_name, composed_id + '_list', prop['type'], aq_id + '_list',
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'), reindex=0)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( write_permission, accessor_name )
property_holder.registerAccessor(accessor_name, composed_id + '_list',
ContentProperty.Setter, list_accessor_args)
property_holder.declareProtected( write_permission, accessor_name )
accessor_name = 'set' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name )
property_holder.registerAccessor(accessor_name, '_' + accessor_name, Alias.Reindex, ())
property_holder.declareProtected( write_permission, accessor_name )
accessor_name = 'set' + UpperCase(composed_id) + 'List'
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name )
property_holder.registerAccessor(accessor_name, '_' + accessor_name, Alias.Reindex, ())
property_holder.declareProtected( write_permission, accessor_name )
# No default getter YET XXXXXXXXXXXXXX
# No list getter YET XXXXXXXXXXXXXX
else:
accessor_args = (prop['type'], prop.get('default'), prop.get('storage_id'))
# Create getters for a simple property
accessor_name = 'get' + UpperCase(id)
accessor = Base.Getter(accessor_name, id,
prop['type'], default=prop.get('default'),
storage_id = prop.get('storage_id'))
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected( read_permission, accessor_name )
property_holder.registerAccessor(accessor_name, id, Base.Getter, accessor_args)
property_holder.declareProtected( read_permission, accessor_name )
accessor_name = '_baseGet' + UpperCase(id)
accessor = accessor.dummy_copy(accessor_name)
if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Base.Getter, accessor_args)
######################################################
# Create Setters
if prop['type'] in list_types or prop.get('multivalued', 0):
# Create setters for a list property by aliasing
setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'List'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
# Create setters for a list property (no reindexing)
# The base accessor sets the list to a singleton
# and allows simulates a simple property
setter_name = '_set' + UpperCase(id)
base_setter = List.Setter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
# The default setter sets the first item of a list
setter_name = '_setDefault' + UpperCase(id)
default_setter = List.DefaultSetter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
# The list setter sets the whole list
setter_name = '_set' + UpperCase(id) + 'List'
list_setter = List.ListSetter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
# The list setter sets the whole list
setter_name = '_set' + UpperCase(id) + 'Set'
set_setter = List.SetSetter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
accessor_args = (prop['type'], prop.get('storage_id'), 0)
# Create setters for a list property
setter_name = '_set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.Setter, accessor_args)
setter_name = '_baseSet' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.Setter, accessor_args)
setter_name = '_setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.DefaultSetter, accessor_args)
setter_name = '_baseSetDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.DefaultSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'List'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, list_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.ListSetter, accessor_args)
setter_name = '_baseSet' + UpperCase(id) + 'List'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, list_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.ListSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, set_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.SetSetter, accessor_args)
setter_name = '_baseSet' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, set_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, List.SetSetter, accessor_args)
elif prop['type'] == 'content':
# Create setters for an object property
# Create setters for a list property (reindexing)
......@@ -1849,72 +1704,67 @@ def createDefaultAccessors(property_holder, id, prop = None,
# Create setters for an object property
setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + base_setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + base_setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + default_setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + default_setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + base_setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + base_setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + default_setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + default_setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
# Create setters for a list property (no reindexing)
# The base accessor sets the list to a singleton
# and allows simulates a simple property
setter_name = '_set' + UpperCase(id)
base_setter = Content.Setter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
# The default setter sets the first item of a list without changing other items
setter_name = '_setDefault' + UpperCase(id)
default_setter = Content.DefaultSetter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
accessor_args = (prop['type'], prop.get('storage_id'), 0)
# Create setters for an object property
setter_name = '_set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.Setter, accessor_args)
setter_name = '_baseSet' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.Setter, accessor_args)
setter_name = '_setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.DefaultSetter, accessor_args)
setter_name = '_baseSetDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.DefaultSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.Setter, accessor_args)
setter_name = '_baseSet' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.Setter, accessor_args)
setter_name = '_setDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.DefaultSetter, accessor_args)
setter_name = '_baseSetDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Content.DefaultSetter, accessor_args)
else:
accessor_args = (prop['type'], prop.get('storage_id'), 0)
# Create setters for a simple property
setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = '_set' + UpperCase(id)
setter = Base.Setter(setter_name, id, prop['type'], reindex=0,
storage_id = prop.get('storage_id'))
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.registerAccessor(setter_name, id, Base.Setter, accessor_args)
setter_name = '_baseSet' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Base.Setter, accessor_args)
######################################################
# Create testers
if prop['type'] == 'content':
# XXX This approach is wrong because testers for all properties
# should be created upfront rather than on demand
tester_name = 'has' + UpperCase(id)
tester = Content.Tester(tester_name, id, prop['type'],
storage_id = prop.get('storage_id'))
......@@ -1953,16 +1803,14 @@ def createDefaultAccessors(property_holder, id, prop = None,
# First Implementation of Boolean Accessor
tester_name = 'is' + UpperCase(id)
tester = Base.Getter(tester_name, id, prop['type'],
storage_id = prop.get('storage_id'))
if not hasattr(property_holder, tester_name):
setattr(property_holder, tester_name, tester)
property_holder.security.declareProtected(read_permission, tester_name)
property_holder.registerAccessor(tester_name, id, Base.Getter,
(prop['type'], prop.get('default'), prop.get('storage_id')))
property_holder.declareProtected(read_permission, tester_name)
tester_name = '_baseIs' + UpperCase(id)
tester = Base.Getter(tester_name, id, prop['type'],
storage_id = prop.get('storage_id'))
if not hasattr(property_holder, tester_name):
setattr(property_holder, tester_name, tester)
property_holder.registerAccessor(tester_name, id, Base.Getter,
(prop['type'], prop.get('default'), prop.get('storage_id')))
from Accessor import Category
......@@ -1974,96 +1822,90 @@ def createCategoryAccessors(property_holder, id,
and a property
"""
accessor_name = 'get' + UpperCase(id) + 'List'
accessor = Category.ListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Category.ListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'List'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Category.ListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'Set'
accessor = Category.SetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Category.SetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'Set'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Category.SetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'ItemList'
accessor = Category.ItemListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Category.ItemListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'getDefault' + UpperCase(id)
accessor = Category.DefaultGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Category.DefaultGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Category.DefaultGetter, ())
accessor_name = 'get' + UpperCase(id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Category.DefaultGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Category.DefaultGetter, ())
setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'List'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name):
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
accessor_args = (0,)
setter_name = '_set' + UpperCase(id)
setter = Category.Setter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.registerAccessor(setter_name, id, Category.Setter, accessor_args)
setter_name = '_categorySet' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Category.Setter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'List'
setter = Category.ListSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.registerAccessor(setter_name, id, Category.ListSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'List'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Category.ListSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'Set'
setter = Category.SetSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.registerAccessor(setter_name, id, Category.SetSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
setter_name = 'set' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Category.SetSetter, accessor_args)
setter_name = '_setDefault' + UpperCase(id)
setter = Category.DefaultSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.registerAccessor(setter_name, id, Category.DefaultSetter, accessor_args)
setter_name = '_categorySetDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.registerAccessor(setter_name, id, Category.DefaultSetter, accessor_args)
from Accessor import Value, Related, RelatedValue, Translation
......@@ -2078,435 +1920,385 @@ def createValueAccessors(property_holder, id,
"""
accessor_name = 'get' + UpperCase(id) + 'ValueList'
accessor = Value.ListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.ListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.ListGetter, ())
accessor_name = UpperCase(id) + 'Values'
accessor_name = string.lower(accessor_name[0]) + accessor_name[1:]
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.ListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'ValueSet'
accessor = Value.SetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.SetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'ValueSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.SetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'TitleList'
accessor = Value.TitleListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.TitleListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'TitleList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.TitleListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'TitleSet'
accessor = Value.TitleSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.TitleSetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'TitleSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.TitleSetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'TranslatedTitleList'
accessor = Value.TranslatedTitleListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.TranslatedTitleListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'TranslatedTitleList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.TranslatedTitleListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'TranslatedTitleSet'
accessor = Value.TranslatedTitleSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.TranslatedTitleSetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'TranslatedTitleSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.TranslatedTitleSetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'ReferenceList'
accessor = Value.ReferenceListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.ReferenceListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'ReferenceList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.ReferenceListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'ReferenceSet'
accessor = Value.ReferenceSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.ReferenceSetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'ReferenceSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.ReferenceSetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'IdList'
accessor = Value.IdListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.IdListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'IdList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.IdListGetter, ())
accessor_name = UpperCase(id) + 'Ids'
accessor_name = string.lower(accessor_name[0]) + accessor_name[1:]
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.IdListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'IdSet'
accessor = Value.IdSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.IdSetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'IdSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.IdSetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'LogicalPathList'
accessor = Value.LogicalPathListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.LogicalPathListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'LogicalPathList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.LogicalPathListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'LogicalPathSet'
accessor = Value.LogicalPathSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.LogicalPathSetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'LogicalPathSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.LogicalPathSetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'UidList'
accessor = Value.UidListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.UidListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'UidList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.UidListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'UidSet'
accessor = Value.UidSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.UidSetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'UidSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.UidSetGetter, ())
accessor_name = 'get' + UpperCase(id) + 'PropertyList'
accessor = Value.PropertyListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.PropertyListGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'PropertyList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.PropertyListGetter, ())
accessor_name = 'get' + UpperCase(id) + 'PropertySet'
accessor = Value.PropertySetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.PropertySetGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'PropertySet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.PropertySetGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'Value'
accessor = Value.DefaultGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultGetter, ())
accessor_name = 'get' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'Value'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'Title'
accessor = Value.DefaultTitleGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'Title'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'Title'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'Title'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'TranslatedTitle'
accessor = Value.DefaultTranslatedTitleGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultTranslatedTitleGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'TranslatedTitle'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultTranslatedTitleGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'TranslatedTitle'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultTranslatedTitleGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'TranslatedTitle'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultTranslatedTitleGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'Reference'
accessor = Value.DefaultReferenceGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultReferenceGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'Reference'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultReferenceGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'Reference'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultReferenceGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'Reference'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultReferenceGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'Uid'
accessor = Value.DefaultUidGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultUidGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultUidGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultUidGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultUidGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'Id'
accessor = Value.DefaultIdGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultIdGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'Id'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultIdGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'Id'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultIdGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'Id'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultIdGetter, ())
accessor = Value.DefaultTitleOrIdGetter(accessor_name, id)
accessor_name = 'getDefault' + UpperCase(id) + 'TitleOrId'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleOrIdGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'TitleOrId'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleOrIdGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'TitleOrId'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleOrIdGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'TitleOrId'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultTitleOrIdGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'Property'
accessor = Value.DefaultIdGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultPropertyGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'Property'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultPropertyGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'Property'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultPropertyGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'Property'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultPropertyGetter, ())
accessor_name = 'getDefault' + UpperCase(id) + 'LogicalPath'
accessor = Value.DefaultLogicalPathGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultLogicalPathGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'LogicalPath'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Value.DefaultLogicalPathGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'LogicalPath'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultLogicalPathGetter, ())
accessor_name = '_categoryGet' + UpperCase(id) + 'LogicalPath'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Value.DefaultLogicalPathGetter, ())
setter_name = 'set' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'ValueSet'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
accessor_args = (0,)
setter_name = '_set' + UpperCase(id) + 'Value'
setter = Value.Setter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.Setter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.Setter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'ValueList'
setter = Value.ListSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.ListSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'ValueList'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.ListSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'ValueSet'
setter = Value.SetSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.SetSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'ValueSet'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.SetSetter, accessor_args)
setter_name = '_setDefault' + UpperCase(id) + 'Value'
setter = Value.DefaultSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.DefaultSetter, accessor_args)
setter_name = '_categorySetDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.DefaultSetter, accessor_args)
# Uid setters
setter_name = 'set' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'UidList'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'UidSet'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, '_' + setter_name, Alias.Reindex, ())
property_holder.declareProtected(write_permission, setter_name)
setter_name = '_set' + UpperCase(id) + 'Uid'
setter = Value.UidSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidSetter, accessor_args)
setter_name = '_setDefault' + UpperCase(id) + 'Uid'
setter = Value.UidDefaultSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidDefaultSetter, accessor_args)
setter_name = '_categorySetDefault' + UpperCase(id) + 'Uid'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidDefaultSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'UidList'
setter = Value.UidListSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidListSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'UidList'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidListSetter, accessor_args)
setter_name = '_set' + UpperCase(id) + 'UidSet'
setter = Value.UidSetSetter(setter_name, id, reindex=0)
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter)
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidSetSetter, accessor_args)
setter_name = '_categorySet' + UpperCase(id) + 'UidSet'
if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
property_holder.security.declareProtected(write_permission, setter_name)
property_holder.registerAccessor(setter_name, id, Value.UidSetSetter, accessor_args)
def createRelatedValueAccessors(property_holder, id,
read_permission=Permissions.AccessContentsInformation,
def createRelatedValueAccessors(id, read_permission=Permissions.AccessContentsInformation,
write_permission=Permissions.ModifyPortalContent):
upper_case_id = UpperCase(id)
# Related Values (ie. reverse relation getters)
# We are not generating here all the related stuff we need
property_holder = BaseClass
# AccessorClass: (accessor_name, )
accessor_dict = {
# List getter
......@@ -2620,20 +2412,20 @@ def createRelatedValueAccessors(property_holder, id,
# First element is the original accessor
accessor_name = accessor_name_list[0]
accessor = accessor_class(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
if not hasattr(BaseClass, accessor_name):
setattr(BaseClass, accessor_name, accessor)
# Declare the security of method which doesn't start with _
if accessor_name[0] != '_':
property_holder.security.declareProtected(permission, accessor_name)
BaseClass.security.declareProtected(permission, accessor_name)
# Others are dummy copies
for accessor_name in accessor_name_list[1:]:
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name,
if not hasattr(BaseClass, accessor_name):
setattr(BaseClass, accessor_name,
accessor.dummy_copy(accessor_name))
# Declare the security of method which doesn't start with _
if accessor_name[0] != '_':
property_holder.security.declareProtected(permission, accessor_name)
BaseClass.security.declareProtected(permission, accessor_name)
def createTranslationAccessors(property_holder, id,
read_permission=Permissions.AccessContentsInformation,
......@@ -2643,20 +2435,19 @@ def createTranslationAccessors(property_holder, id,
"""
if 'translated' in id:
accessor_name = 'get' + UpperCase(id)
accessor = Translation.TranslatedPropertyGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
property_holder.registerAccessor(accessor_name, id, Translation.TranslatedPropertyGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
accessor_name = '_baseGet' + UpperCase(id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.registerAccessor(accessor_name, id, Translation.TranslatedPropertyGetter, ())
if 'translation_domain' in id:
# Getter
accessor_name = 'get' + UpperCase(id)
accessor = Translation.PropertyTranslationDomainGetter(accessor_name, id, "" ,default=default)
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
if not hasattr(property_holder, accessor_name):
property_holder.registerAccessor(accessor_name, id, Translation.PropertyTranslationDomainGetter, ())
property_holder.declareProtected(read_permission, accessor_name)
#####################################################
......
......@@ -13,6 +13,7 @@
##############################################################################
from zLOG import LOG, WARNING
from types import StringTypes
# Make sure Interaction Workflows are called even if method not wrapped
......@@ -29,11 +30,17 @@ from Products.CMFCore.utils import _getAuthenticatedUser
from Products.ERP5Type.Cache import CachingMethod
from sets import ImmutableSet
def DCWorkflowDefinition_notifyWorkflowMethod(self, ob, method_id, args=None, kw=None, transition_list=None):
def DCWorkflowDefinition_notifyWorkflowMethod(self, ob, transition_list, args=None, kw=None):
'''
Allows the system to request a workflow action. This method
must perform its own security checks.
'''
if type(transition_list) in StringTypes:
method_id = transition_list
elif len(transition_list) == 1:
method_id = transition_list[0]
else:
raise ValueError('WorkflowMethod should be attached to exactly 1 transition per DCWorkflow instance.')
sdef = self._getWorkflowStateOf(ob)
if sdef is None:
raise WorkflowException, 'Object is in an undefined state'
......@@ -54,7 +61,7 @@ def DCWorkflowDefinition_notifyWorkflowMethod(self, ob, method_id, args=None, kw
activate_kw = {}
ob.reindexObject(activate_kw=activate_kw)
def DCWorkflowDefinition_notifyBefore(self, ob, action, args=None, kw=None, transition_list=None):
def DCWorkflowDefinition_notifyBefore(self, ob, transition_list, args=None, kw=None):
'''
Notifies this workflow of an action before it happens,
allowing veto by exception. Unless an exception is thrown, either
......@@ -63,7 +70,7 @@ def DCWorkflowDefinition_notifyBefore(self, ob, action, args=None, kw=None, tran
'''
pass
def DCWorkflowDefinition_notifySuccess(self, ob, action, result, args=None, kw=None, transition_list=None):
def DCWorkflowDefinition_notifySuccess(self, ob, transition_list, result, args=None, kw=None):
'''
Notifies this workflow that an action has taken place.
'''
......
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