Hi Chris!

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

That may be, but how would you code what's being done above?

I wouldn't code it at all because it makes too many assumptions about the CMFDefault configuration. A product like Plone should ship with its own configuration instead of running a set of transformations against the CMFDefault configuration.

It seems like a moderately legitimate use to me, but I may be missing something :-S

getActionByID has irresolvable bugs because it tries to do something impossible.

And what is that?

The Action URL depends on the actual request and user. And the method returned by that URL might be something completely different. There is no general answer to the question which method is called by a specific Action.

It only does what you expect as long as you make sure your action expressions are parsable by getActionByID.

What does that mean, in simple terms?

You have to make sure that the last part of the URL is the name of the method and that it doesn't depend on variables that are different in different requests.

I doubt your use case is a legit use case.

As I said before, how would you code the above?

What are the "plenty more apparently legit uses of getActionByID"?

Well, legit may be the wrong word, but "I can't thing how to implement this other than by having a getActionById" :-(
Anyway, here they are:

- in CMFPlone/PloneTool.py, getActionById is used to return only the last segment of the URL for the action. Surely getActionInfo()['url'] returns the whole url?

Mindyou, what would you expect:
type_info.getActionInfo('object/view')['url']
...to return? The complete url, or just the thing to be appended on the end of the object's url?

If it's the latter, I think it's a grossly misnamed key :-(
Why isn't it called url_segment?

Yes. It returns what you expect.

Actions just define redirect targets and UI elements for manual redirects (== menu items).

If you need a method ID, use queryMethodID.

In CMFPlone/PloneTool.py getActionById is used for fallback layer 6 and 7! I don't know in which cases that code is ever called. Using queryMethodID should give similar results if 'folderlisting' and 'view' aliases are set correctly.


Cheers,

        Yuppie

_______________________________________________
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

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

Reply via email to