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

Yuppie schubbe at web.de
Mon Nov 17 07:53:29 EST 2003


Hi!


Sidnei da Silva wrote:
> | 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.
> 
> Sounds good to me. I don't think it will cause significant difference
> on the results to break existing apps, but correct me if I'm wrong.

The results should be exactly the same.

> | It's not enforced these paths are unique, but duplicates are ignored.
> 
> +1, and it would be good to have some kind of warning when they are ignored.

If I find an easy solution I'll add a warning.

> |     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
> |         """
> 
> Looks good, though I don't know what the action_chain parameter is for <wink>

Oops! Should have explained this.

I'd like to use getActionInfo for redirects instead of getActionById.
In this use case action_chain would provide a fallback chain, e.g.
   <code>
     action_chain = ('object/edit', 'object/view')
     ti = context.getTypeInfo()
     target = ti.getActionInfo(context, action_chain)['url']
     context.REQUEST.RESPONSE.redirect(target)
   </code>
would redirect to 'object/edit' if the action exists and the user has a 
permission and the condition is true (I guess check_visibility should 
better default to 0 in getActionInfo). If not, this code tries to 
redirect to 'object/view'.

In listActionInfos action_chain is used by getActionInfo. An other use 
case would be pre-selecting actions and their order.


Cheers,
	Yuppie





More information about the Zope-CMF mailing list