[Erp5-report] r29650 - in /erp5/trunk/products/ERP5Type: ./ Tool/ interfaces/ patches/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Oct 14 15:18:29 CEST 2009
Author: kazuhiko
Date: Wed Oct 14 15:18:25 2009
New Revision: 29650
URL: http://svn.erp5.org?rev=29650&view=rev
Log:
* add getActionListFor() that does not filter (cf. getFilteredActionListFor() filters).
* revert r29647 and use getActionListFor() and call test() for its result in getDefaultViewFor(), so that createExpressionContext() is only called once.
* use getActionListFor() and call test() for its result in listFilteredActionsFor(), so that createExpressionContext() is only called once..
Modified:
erp5/trunk/products/ERP5Type/ERP5Type.py
erp5/trunk/products/ERP5Type/Tool/TypesTool.py
erp5/trunk/products/ERP5Type/interfaces/action_provider.py
erp5/trunk/products/ERP5Type/patches/ActionsTool.py
Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=29650&r1=29649&r2=29650&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] Wed Oct 14 15:18:25 2009
@@ -497,15 +497,16 @@
"""
ec = createExpressionContext(ob)
best_action = (), None
- for action in self.getFilteredActionListFor(ob):
+ for action in self.getActionListFor(ob):
if action.getReference() == view:
- break
+ if action.test(ec):
+ break
else:
# In case that "view" (or "list") action is not present or not allowed,
# find something that's allowed (of the same category, if possible).
index = (action.getActionType().endswith('_' + view),
-action.getFloatIndex())
- if best_action[0] < index:
+ if best_action[0] < index and action.test(ec):
best_action = index, action
else:
action = best_action[1]
@@ -518,6 +519,11 @@
target = target[1:]
__traceback_info__ = self.getId(), target
return ob.restrictedTraverse(target)
+
+ security.declarePrivate('getActionListFor')
+ def getActionListFor(self, ob=None):
+ """Return all actions of the object"""
+ return self.getActionInformationList()
security.declarePrivate('getFilteredActionListFor')
def getFilteredActionListFor(self, ob=None):
Modified: erp5/trunk/products/ERP5Type/Tool/TypesTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/TypesTool.py?rev=29650&r1=29649&r2=29650&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/TypesTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/TypesTool.py [utf8] Wed Oct 14 15:18:25 2009
@@ -41,6 +41,15 @@
security.declareObjectProtected(Permissions.AccessContentsInformation)
zope.interface.implements(interfaces.IActionProvider)
+
+ security.declarePrivate('getActionListFor')
+ def getActionListFor(self, ob=None):
+ """Return all actions of the object"""
+ if ob is not None:
+ type_info = self.getTypeInfo(ob)
+ if type_info is not None:
+ return type_info.getActionListFor(ob)
+ return ()
security.declarePrivate('getFilteredActionListFor')
def getFilteredActionListFor(self, ob=None):
Modified: erp5/trunk/products/ERP5Type/interfaces/action_provider.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/interfaces/action_provider.py?rev=29650&r1=29649&r2=29650&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/interfaces/action_provider.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/interfaces/action_provider.py [utf8] Wed Oct 14 15:18:25 2009
@@ -53,6 +53,9 @@
class IActionProvider(Interface):
"""
"""
+ def getActionListFor(ob):
+ """Return all actions of the object"""
+
def getFilteredActionListFor(ob):
"""Return all actions applicable to the object
"""
Modified: erp5/trunk/products/ERP5Type/patches/ActionsTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/ActionsTool.py?rev=29650&r1=29649&r2=29650&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/ActionsTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/ActionsTool.py [utf8] Wed Oct 14 15:18:25 2009
@@ -36,12 +36,13 @@
provider = getattr(self, provider_name)
if providedBy(provider):
actions.extend( provider.listActionInfos(object=object) )
- elif hasattr(provider, 'getFilteredActionListFor'):
+ elif hasattr(provider, 'getActionListFor'):
from Products.ERP5Type.Utils import createExpressionContext
ec = createExpressionContext(object)
actions += sorted(
(action.getActionInfo(ec)
- for action in provider.getFilteredActionListFor(object)),
+ for action in provider.getActionListFor(object)
+ if action.test(ec)),
key=lambda x: x['priority'])
else:
# for Action Providers written for CMF versions before 1.5
More information about the Erp5-report
mailing list