[Zope-CMF] Re: [dev] refactoring listFilteredActionsFor: a proposal
(updated interface)
Yuppie
schubbe at web.de
Wed Nov 19 07:04:34 EST 2003
Hi Tres!
Tres Seaver wrote:
> On Tue, 2003-11-18 at 03:51, Yuppie wrote:
>>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.
Well. I tend in the other direction. Making the method public, just not
publishable.
I'd like to have 'object' as *the* argument passed around:
- listFilteredActionsFor already takes 'object' as argument.
- getActionInfo should take 'object' to make it easier to use.
- We still have the WorkflowTool with an OldstyleActionProvider
Interface. It needs 'info', not an ExpressionContext. Passing in
'object' would allow the ActionProviders to create what they need.
- I'd like to deprecate the use of 'info' for newstyle ActionProviders.
TypesTool (and an updated WorkflowTool) would still need the object
passed into listActions.
- Zope3 also uses 'object' to get menu items.
This is the current state of the interface I'd like to implement:
def listActions(info=None, object=None):
""" List all the actions defined by a provider.
If 'object' is specified, object specific actions are included.
The 'info' argument is deprecated and may be removed in a future
version. If 'object' isn't specified, the method uses for
backwards compatibility 'info.content' as object.
Returns -- Tuple of ActionInformation objects
"""
def listActionInfos(action_chain=None, object=None,
check_visibility=1, check_permissions=1,
check_condition=1, max=-1):
""" List Action info mappings.
'action_chain' is a sequence of action 'paths' (e.g.
'object/view'). If specified, only these actions will be
returned in the given order.
If 'object' is specified, object specific Actions are included.
If 'max' is specified, only the first max Actions are returned.
Permission -- Always available (not publishable)
Returns -- Tuple of Action info mappings
"""
def getActionInfo(action_chain, object=None, check_visibility=0):
""" Get an Action info mapping specified by a chain of actions.
Permission -- Always available
Returns -- Action info mapping or None
"""
listFilteredActionsFor would look for the listActionInfos attribute. If
it doesn't exist, listFilteredActionsFor uses the old code for backwards
compatibility.
Please let me know if you still would prefer ExpressionContext as
argument for listActionInfos.
Cheers,
Yuppie
More information about the Zope-CMF
mailing list