[Zope-CMF] Re: getActionById replacement

yuppie y.2005- at wcm-solutions.de
Thu Oct 20 13:13:25 EDT 2005


Hi Chris!


Chris Withers wrote:
> yuppie wrote:
>>> getActionInfo()[\'url\']
>>>
>>> ...will net you a TypeError explaining that getActionInfo takes a 
>>> argument that isn't supplied. Looking at the docs, an action_chain, 
>>> but I have no idea what one of them is...
>>
>> 'action_chain' is a sequence of 'action paths'.
> 
> Does supplying a chain return the first action info that matches or the 
> first or all of the ones that match?

listActionInfos() returns a tuple of ActionInfo objects, getActionInfo() 
the first ActionInfo that passes the checks. Note that ActionInfo is a 
dict, not the persistent Action object you need.

>> 'action paths' are the unique identifiers of Actions. 'view' doesn't 
>> identify an Action because there might be 'object/view' and 
>> 'foo/view'. 'action paths' have the format <category>/<id>.
> 
> Ah, okay, so what does getActionById('view'), in its deprecated form, 
> actually do?

It returns the first 'view' Action it finds.

> My current guess is to what SHOULD be used is:
> 
>  >>>ti.getActionInfo('object/view')
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File
> "Products/CMFCore/ActionProviderBase.py", line 128, in getActionInfo
>     raise AccessControl_Unauthorized('You are not allowed to access any '
> AccessControl.unauthorized.Unauthorized: You are not allowed to access any
> of the specified Actions.
> 
> ...but as you can see, that's not too successful :-(
> The above was from a 'zopectl debug' prompt, what am I doing wrong?

Not quite sure, but I guess you have problems to get a useful expression 
context.

Once again:

getActionObject(action_path) is the method you are looking for.

ti.getActionObject('object/view') should work for you.


HTH,

	Yuppie



More information about the Zope-CMF mailing list