[Zope-CMF] Re: Method Aliases
Dieter Maurer
dieter at handshake.de
Wed Oct 8 13:33:04 EDT 2003
Yuppie wrote at 2003-10-8 18:49 +0200:
> if len(default_path) > 1:
> path = list(default_path)
> method = path.pop()
> > > request['TraversalRequestNameStack'] = path
> > > continue
> > > else:
> > > - method = default_path[0]
> > > - entry_name = method
> > > + entry_name = default_path[0]
> > > elif (method and hasattr(object,method)
> > > and entry_name != method
> > > and getattr(object, method) is not None):
> > > request._hacked_path=1
> > > entry_name = method
> > > + method = 'index_html'
> > > else:
> > > if (hasattr(object, '__call__') and
> > > hasattr(object.__call__,'__roles__')):
> > > </diff>
> >
> > With your first change, you ensure that "method" is no longer
> > modified. Therefore, the second change is not necessary.
>
> I added 3 more lines to the diff above. Hope that makes it clearer. The
> first change affects just the else clause. The second change is
> necessary for the if clause.
Note also that when you change the traversal path, you change the effective
URL and make relative URL references invalid unless you tell
the browser about the new effective URL (by creating a "base" tag).
The "request._hacked_path=1" takes care for this.
Formerly, the "request._hacked_path=1" in the "elif" branch was
sufficient. Now, the same is necessary in your "if len(default_path) > 1".
I filed a bug report for this in the CMF collector with respect
to "DynamicType". However, it would be better to fix it here.
Dieter
More information about the Zope-CMF
mailing list