[Zope-CMF] [dev] refactoring listFilteredActionsFor: a proposal

Yuppie schubbe at web.de
Sun Nov 16 13:08:35 EST 2003


Hi!


Overview / Goals:

1.) acceleration of listFilteredActionsFor:
   reduce expensive evaluation of Expressions

2.) identification of Actions:
   define an unique key for Actions

3.) modularization of listFilteredActionsFor:
   allow querying particular Action Providers

For discussion regarding 2.) and 3.), see this thread:
   <http://mail.zope.org/pipermail/zope-cmf/2003-October/019548.html>



Details / Proposal:


1.)
Actions are filtered on visibility, permissions and condition.
Currently we have this order:
   - filter on condition
   - evaluate action Expression
   - filter on visibility
   - filter on permissions

I propose this order:
   - filter on visibility (least expensive)
   - filter on permissions
   - filter on condition (most expensive)
   - evaluate action Expression

This speeds up listFilteredActionsFor significantly.


2.)
Action ids aren't unique.
I propose to identify actions by a path '<category>/<id>', e.g.:
   'object/edit', 'object/folderContents', 'folder/folderContents'

It's not enforced these paths are unique, but duplicates are ignored.


3.)
Action Providers should have a method that filters Actions. To avoid 
redundant code, listFilteredActionsFor could use this new method instead 
of listActions. The function of listFilteredActionsFor would not be 
filtering actions anymore, but aggregating actions from different 
sources and bucketing them into categories.

I propose to add these methods to the ActionProvider Interface:

     def listActionInfos(action_chain=None, object=None, ec=None,
                         max=999, check_visibility=1,
                         check_permissions=1, check_condition=1):
         """ List Action info mappings.

         Permission -- Python only

         Returns -- Tuple of Action info mappings
         """

     def getActionInfo(action_chain, object=None, check_visibility=1):
         """ Get an Action info mapping specified by a chain of actions.

         Permission -- Always available

         Returns -- Action info mapping or None
         """


Any feedback is welcome!


Cheers,
	Yuppie





More information about the Zope-CMF mailing list