[Zope-CMF] Re: possible bug,
action condition not obeyed by _getViewFor
Yuppie
schubbe at web.de
Fri Nov 21 05:49:57 EST 2003
Hi!
Dieter Maurer wrote:
> Sune Brøndum Wøller wrote at 2003-11-20 01:43 +0100:
> > possible bug:
> > The _getViewFor in utils.py doesn't obey the condition
> > set on the action.
> > (it only checks permissions)
> >
> > Context : when defining two 'view' actions on a portal type
> > with mutually exclusive conditions.
> >
> > I try to use it to have different default views depending on
> > whether the user is logged in.
> >
> > should it be posted in the collector ?
>
> Yuppie is working on a proposal to forbid non-unique action ids
> (in the same catagorie).
>
> Unless you have a strong reason, your use will soon result in
> a proper exception ("duplicate action id").
> Read the recent discussion in this list and make your voice heard...
That's not exactly right:
1.) CMF 1.5 will be 100% backwards compatible regarding non-unique
action ids. My proposal just says that duplicates are ignored if you use
the new 'action_chain' argument. CMF 1.6 might have the behavior Dieter
describes.
2.) You can easily rewrite your mutually exclusive conditions to an
action Expression of *one* Action:
python: member and member_view_url or public_view_url
That doesn't resolve your problem because _getViewFor has member always
set to None, but it shows that unique actions are no problem for your
use case.
3.) _getViewFor has a lot of other bugs, if you ask me it's just a
backwards compatibility hack. You weren't able to use conditions or
Expressions in CMF 1.3 type actions, so these are the things that don't
work right in CMF 1.4's _getViewFor.
That's why I implemented Method Aliases for CMF 1.5. The version in CVS
HEAD ignores _getViewFor completely and I hope _getViewFor can be
removed in a future version of CMF. I'm not going to fix any _getViewFor
bugs.
4.) Your use case can't be resolved with Method Aliases.
Depending on your needs I would try one of these approachs:
- using different blocks in your templates
<tal:case tal:condition="isAnon"></tal:case>
<tal:case tal:condition="not:isAnon"></tal:case>
- using different URLs
www.example.org/myDocument
www.example.org/myDocument/member_view
- using different skins
Cheers,
Yuppie
More information about the Zope-CMF
mailing list