[Zope-CMF] [dev] type actions, views and aliases: a proposal
Peter Simmons
pete@bcmpweb.com
Sat, 21 Jun 2003 10:49:19 +1200
I like your proposal. Another instance where we found the view method to
get in the way was when we needed to make users be content. I know since
then there has been something else which does this but we did it by
diabling the view method and removing the __call__ attribute so that we
could then use the instance in __of__ calls in MemberDataTool that wrap
the user object with the member data.
This of course broke some of the behaviour. So we went through all the
templates that were used and fixed them to make the getActionById call.
It would have been a lot easier to just have that mapping and do it in
one place.
Pete
Yuppie wrote:
> 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
>
>
>
>
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>
>