Chris Withers wrote:
Ah, okay, so what does getActionById('view'), in its deprecated form,
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.
Seems I successfully tried to forget the ugly things it does;) You are
right. It's always a good idea to look at the code.
getActionObject(action_path) is the method you are looking for.
ti.getActionObject('object/view') should work for you.
Well, that returns an action object :-(
Oops! Should have had a better look at the Plone code. I thought you
need the 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 :-(
Well. getActionByID did make sense before type actions became normal
actions in CMF 1.4. Since than getActionByID is an ugly backwards
compatibility hack that tries to guess the called method from an
expression string that defines a context dependent URL.
getActionByID has irresolvable bugs because it tries to do something
impossible. It only does what you expect as long as you make sure your
action expressions are parsable by getActionByID.
I doubt your use case is a legit use case. If you just want the
deprecation warnings "to STFU" you have to reimplement getActionByID. If
you want to do things right, you don't need a replacement for getActionByID.
What are the "plenty more apparently legit uses of getActionByID"?
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests