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

Tres Seaver tseaver at zope.com
Tue Nov 18 08:08:21 EST 2003


On Tue, 2003-11-18 at 03:51, Yuppie wrote:
> Dieter Maurer wrote:
> > Yuppie wrote at 2003-11-16 19:08 +0100:
> >  > 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.

<<snip>>

> >  > 
> >  >          Returns -- Tuple of Action info mappings
> >  >          """
> > 
> > Proposals should not only provide the method's signature
> > but also describe (at least) the arguments and the return value.
> 
> Sorry.
> 
> 'action_chain' is a sequence of action 'paths' (e.g. 'object/view').
> If specified, only these actions will be returned in the given order. 
> see <http://mail.zope.org/pipermail/zope-cmf/2003-November/019805.html>
> 
> If 'object' is specified, object specific actions are included. If 'ec' 
> isn't specified, this object be used for creating the Expression Context.
> 
> 'ec' is the Expression Context used to evaluate Expressions. If 'object' 
> isn't specified, object will be taken from this argument.
> 
> The rest should be obvious. 'Action info mappings' are the dicts 
> getAction() returns.
> 
> I'm not really happy with having 'object' *and* 'ec' as argument. But it 
> makes listFilteredActionsFor faster if the Expression Context isn't 
> build by each Action Provider. And on the other hand I'd like to have 
> the possibility to pass in just the object. Would one 'context' argument 
> be better that checks if the value is an Expression Context? Or 
> shouldn't we care about performance and always build a new context from 
> 'object'? (I guess it wouldn't slow down listFilteredActionsFor 
> significantly.)

I would actually prefer to require that the caller construct an
ExpressionContext, especially as you are not trying to open the method
up to scripting.

> > I am scared about the "max" argument.
> > When you anticipate the need for such an argument, then you
> > should almost surely provide some way to limit the amount
> > of entries returned (such as e.g. interesting categories)
> > Some feedback may be required that the list has been truncated, as well.
> 
> The use case I had in mind for 'max' is returning only the first result. 
> This is used in combination with 'action_chain'. It doesn't make much 
> sense to evaluate the fallback actions if we found an action that passes 
> the checks. Would a 'only_first' flag better than 'max'?

Or make the argument a negative, such as 'include_all_candidates'.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com





More information about the Zope-CMF mailing list