diff --git a/product/CMFActivity/ActiveObject.py b/product/CMFActivity/ActiveObject.py index 498b48ea0537a09d31047e453703e8059dd13175..a813627619736bf737f993df6f912fc200a9a1f6 100644 --- a/product/CMFActivity/ActiveObject.py +++ b/product/CMFActivity/ActiveObject.py @@ -195,12 +195,28 @@ class ActiveObject(ExtensionClass.Base): tv[key] = kw security.declareProtected( permissions.View, 'getDefaultActivateParameterDict' ) - def getDefaultActivateParameterDict(self): + def getDefaultActivateParameterDict(self, inherit_placess=True): # This method returns default activate parameters to self. # The result can be either a dict object or None. tv = getTransactionalVariable(self) - key = ('default_activate_parameter', id(aq_base(self))) - return tv.get(key) + if inherit_placess: + placeless = tv.get(('default_activate_parameter', )) + if placeless is not None: + placeless = placeless.copy() + else: + placeless = None + local = tv.get(('default_activate_parameter', id(aq_base(self)))) + if local is None: + result = placeless + else: + if placeless is None: + result = local.copy() + else: + # local defaults takes precedence over placeless defaults. + result = {} + result.update(placeless) + result.update(local) + return result def getActivityRuntimeEnvironment(self): return getActivityRuntimeEnvironment() diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py index e90cec109ac902d0ed39b5bee81b690d842a0ce9..aab21cf4f5ed5298a1b66abcf7b2559eb9520af2 100644 --- a/product/ERP5/ERP5Site.py +++ b/product/ERP5/ERP5Site.py @@ -33,6 +33,7 @@ from Products.ERP5.Document.BusinessTemplate import BusinessTemplate from Products.ERP5Type.Log import log as unrestrictedLog from Products.CMFActivity.Errors import ActivityPendingError import ERP5Defaults +from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from zLOG import LOG, INFO from string import join @@ -1094,6 +1095,40 @@ class ERP5Site(FolderMixIn, CMFSite): DeprecationWarning) unrestrictedLog(description, content = content, level = level) + security.declarePublic('setPlacelessDefaultReindexParameters') + def setPlacelessDefaultReindexParameters(self, **kw): + # This method sets the default keyword parameters to reindex. This is useful + # when you need to specify special parameters implicitly (e.g. to reindexObject). + # Those parameters will affect all reindex calls, not just ones on self. + tv = getTransactionalVariable(self) + key = ('default_reindex_parameter', ) + tv[key] = kw + + security.declarePublic('setPlacelessDefaultActivateParameters') + def setPlacelessDefaultActivateParameters(self, **kw): + # This method sets the default keyword parameters to activate. This is useful + # when you need to specify special parameters implicitly (e.g. to reindexObject). + # Those parameters will affect all activate calls, not just ones on self. + tv = getTransactionalVariable(self) + key = ('default_activate_parameter', ) + tv[key] = kw + + security.declarePublic('getPlacelessDefaultReindexParameters') + def getPlacelessDefaultReindexParameters(self): + # This method returns default reindex parameters to self. + # The result can be either a dict object or None. + tv = getTransactionalVariable(self) + key = ('default_reindex_parameter', ) + return tv.get(key) + + security.declarePublic('getPlacelessDefaultActivateParameters') + def getPlacelessDefaultActivateParameters(self): + # This method returns default activate parameters to self. + # The result can be either a dict object or None. + tv = getTransactionalVariable(self) + key = ('default_activate_parameter', ) + return tv.get(key) + Globals.InitializeClass(ERP5Site) def getBootstrapDirectory(): diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index e5cce4b658f049a811e9e5e4ee435b79de341b11..ee04e48dd8fde4e2910f39a76220b05581babcc3 100644 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -3577,12 +3577,28 @@ class Base( CopyContainer, tv[key] = kw security.declareProtected(Permissions.View, 'getDefaultReindexParameterDict' ) - def getDefaultReindexParameterDict(self): + def getDefaultReindexParameterDict(self, inherit_placess=True): # This method returns default reindex parameters to self. # The result can be either a dict object or None. tv = getTransactionalVariable(self) - key = ('default_reindex_parameter', id(aq_base(self))) - return tv.get(key) + if inherit_placess: + placeless = tv.get(('default_reindex_parameter', )) + if placeless is not None: + placeless = placeless.copy() + else: + placeless = None + local = tv.get(('default_reindex_parameter', id(aq_base(self)))) + if local is None: + result = placeless + else: + if placeless is None: + result = local.copy() + else: + # local defaults takes precedence over placeless defaults. + result = {} + result.update(placeless) + result.update(local) + return result security.declareProtected(Permissions.View, 'isItem' ) def isItem(self):