yuppie wrote:
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.

Ah, okay, dunno how I ended up on that trail...

'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.

I dug deeper, not quite true ;-)
It gets the 'view' action object and evaluates it's action attribute in a newly created expression context, strips off the leading slash if there is one and then returns the result.

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

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

Well, that returns an action object :-(

Now in plone, they do:


The best I've managed to come up with to replace that is:

from Products.CMFCore.utils import getActionContext
for possible in ('object/view','folder/view'):
    action = typeInfo.getActionObject(possible)
    if action is not None:
    raise RuntimeError('No sensible view found for'+repr(typeInfo))

...which seems pretty heavyweight to me :-S

There's also plenty more apprently legit uses of getActionByID in the code, which has left me wondering exactly why this method was deprecated, given that the suggested replacements don't really seem to cut it :-(



Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk
Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to