[Zope-CMF] [dev] type actions, views and aliases: a proposal

Florent Guillaume fg@nuxeo.com
Wed, 25 Jun 2003 12:53:12 +0200


Hi,

I like the idea in principle, but have concerns with the way it's
configured.

Basically what you're having is, for each Action, a new property
associated to it, let's call it traversal_alias. I would want this new
field to be present in the Actions in the types tool, which is its
natural place.


I must say I've not followed that closely the refactoring of the
Actions, and the semantics now associated to the actions field of an
Action. Would you mind doing a short writeup of these semantics ?

The way I understand them is:

 - the actions field is a full contextual URL, destined to the UI,

 - because _getViewFor and getActionById are used to find a method, they
   have to extract it from the above URL using a hack (passing a
   context-less expression-context, with an empty object_url and then
   stripping resulting the initial slash).

If that's how it works, that's good for backward compat, but in CMF 1.5
I'd like to see:

 - an actions field that gets an URL,
 - a method field that gets a method name (suitable for restrictedTraverse),
 - and, to implement your proposal, a traverse_alias field.

Really, these things are a component of the Action, so that's where they
should live. Now it may be the case that Actions are not well designed
to be extended, but I think the fix should be there.

Note that there are other things I'd like to be able to add to Actions,
for instance an icon name, an i18n msgid, etc.

Florent


In article <3EF2F01E.2090509@web.de> you write:
> Hi!
> 
> Today is my proposal day. Here is the second one:
> 
> 
> Context / Problem
> =================
> 
> I'm still not happy with the limitations for type actions caused by 
> getActionById and _getViewFor.
> 
> _getViewFor is used by the view() method to return the default view.
> 
> 
> The view method allows to add a simple +'/view' to urls.
> 
> www.example.org/foo/view
> 
> is an alias for
> 
> www.example.org/foo/document_view
> -or-
> www.example.org/foo/newsitem_view
> -or-
> www.example.org/foo/whatever_the_default_view_is
> 
> 
> But we can't get rid of these urls, because we can't use them in 
> actions. If we would add an action like that,
> 
> { 'id':'view',
>    'name':'View',
>    'action':'string:${object_url}/view',
>    'permissions':(View,) }
> 
> there would be no way to find out that /view is an alias for 
> /document_view, because actions are currently used to look up these 
> method aliases.
> 
> getActionById does something similar, so this is what I propose:
> 
> 
> 
> Proposal / Solution
> ===================
> 
> I'd like to add a dictionary to TypeInformations that maps aliases to 
> methods and is configurable TTW.
> 
> e.g.
> {'view':'document_view',
>   'edit':'document_edit_form',
>   'metadata':'metadata_edit_form'}
> 
> That might look like redundant information, because right now we can get 
> this information from the actions. But the need to store this 
> information inside actions limits the use of actions right now and makes 
> type actions different from other actions.
> 
> getActionById and _getViewFor could use that dict instead of actions. In 
> fact they'll become useless:
> 
> A __before_publishing_traverse__ in PortalContent could do the mapping.
> That allows to always use the defined aliases, e.g.:
> 
> www.example.org/foo/view
> www.example.org/foo/edit
> www.example.org/foo/metadata
> 
> 
> 
> Any thoughts? Comments are welcome.
> 
> 
> Cheers,
> 
> Yuppie


-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com