Commit 1d72c7de authored by Vincent Pelletier's avatar Vincent Pelletier

Add support for placeless default activate/reindex parameters.

 * Add site-level accessors
 * Modify existing getters to use placeless parameters as default values, context-sensitive parameters being given higher priority.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23471 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e7ae85b1
...@@ -195,12 +195,28 @@ class ActiveObject(ExtensionClass.Base): ...@@ -195,12 +195,28 @@ class ActiveObject(ExtensionClass.Base):
tv[key] = kw tv[key] = kw
security.declareProtected( permissions.View, 'getDefaultActivateParameterDict' ) security.declareProtected( permissions.View, 'getDefaultActivateParameterDict' )
def getDefaultActivateParameterDict(self): def getDefaultActivateParameterDict(self, inherit_placess=True):
# This method returns default activate parameters to self. # This method returns default activate parameters to self.
# The result can be either a dict object or None. # The result can be either a dict object or None.
tv = getTransactionalVariable(self) tv = getTransactionalVariable(self)
key = ('default_activate_parameter', id(aq_base(self))) if inherit_placess:
return tv.get(key) 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): def getActivityRuntimeEnvironment(self):
return getActivityRuntimeEnvironment() return getActivityRuntimeEnvironment()
...@@ -33,6 +33,7 @@ from Products.ERP5.Document.BusinessTemplate import BusinessTemplate ...@@ -33,6 +33,7 @@ from Products.ERP5.Document.BusinessTemplate import BusinessTemplate
from Products.ERP5Type.Log import log as unrestrictedLog from Products.ERP5Type.Log import log as unrestrictedLog
from Products.CMFActivity.Errors import ActivityPendingError from Products.CMFActivity.Errors import ActivityPendingError
import ERP5Defaults import ERP5Defaults
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, INFO from zLOG import LOG, INFO
from string import join from string import join
...@@ -1094,6 +1095,40 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -1094,6 +1095,40 @@ class ERP5Site(FolderMixIn, CMFSite):
DeprecationWarning) DeprecationWarning)
unrestrictedLog(description, content = content, level = level) 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) Globals.InitializeClass(ERP5Site)
def getBootstrapDirectory(): def getBootstrapDirectory():
......
...@@ -3577,12 +3577,28 @@ class Base( CopyContainer, ...@@ -3577,12 +3577,28 @@ class Base( CopyContainer,
tv[key] = kw tv[key] = kw
security.declareProtected(Permissions.View, 'getDefaultReindexParameterDict' ) security.declareProtected(Permissions.View, 'getDefaultReindexParameterDict' )
def getDefaultReindexParameterDict(self): def getDefaultReindexParameterDict(self, inherit_placess=True):
# This method returns default reindex parameters to self. # This method returns default reindex parameters to self.
# The result can be either a dict object or None. # The result can be either a dict object or None.
tv = getTransactionalVariable(self) tv = getTransactionalVariable(self)
key = ('default_reindex_parameter', id(aq_base(self))) if inherit_placess:
return tv.get(key) 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' ) security.declareProtected(Permissions.View, 'isItem' )
def isItem(self): def isItem(self):
......
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