[Zope-CMF] Re: __browser_default__ broken in CMF 1.4.x
Shane Hathaway
shane at zope.com
Mon Sep 29 16:07:12 EDT 2003
Andy McKay wrote:
> One simple hack is to stop appending to the path if its already in there
> something horribly hideous like changing line 113 of DynamicType from:
>
> if id is not '(Default)':
>
> to
>
> if id is not '(Default)' and id not in REQUEST['URL'].split('/'):
>
> Works but is quite horrible.
In more ways than one! Never use "is" with strings. Here is one way it
fails:
>>> str(u'a') is 'a'
False
Also, I think that while method aliases are a good idea, implementing
them with a traversal hack is a bad idea. It will kill whatever
performance we have left after all the other hacks we've done. It's
shoehorning too much into Zope 2.
The more interesting thing to do is to make something acquired from the
root of the portal that dispatches to skin methods based on the type of
the context. For example, if we want an "edit" method alias, we might
create a skin method called "edit" that dispatches to "document_edit" if
it's applied to a document, "news_edit" for news, etc. We could
continue to use the existing machinery for setting up aliases, but we
wouldn't use a traversal hook.
Shane
More information about the Zope-CMF
mailing list