[Zope-CMF] Re: __browser_default__ broken in CMF 1.4.x

Andy McKay andy at agmweb.ca
Mon Sep 29 13:34:37 EDT 2003


Hi,

Thanks for great reply. I have a bad cold so brain is not fully
functioning at the moment.

> Note: This is about CMF HEAD, not CMF 1.4.x .

Phew. That means it doesnt have to be fixed today :)

  > Grepping through Plone HEAD, I found PloneFolder has a
> __browser_default__ method. Looks like Plone's __browser_default__ does 
> something similar to CMF HEAD's __before_publishing_traverse__: 
> Manipulating the default view. I can't see right now why exactly this 
> leads to an infinite loop. Maybe you could provide further information.

The key is in ZPublisher/BaseRequest.py, when an object is accessed its
assumed the default call is index_html. If that object (PloneFolder) has
a __browser_default__ method then its called and that value is used
instead of index_html.

The upshot is we let Plone users enter a series of default pages like
index.html, index.htm, FrontPage etc, we find the one that matches and
make that the default page for the folder.

However with that method in there it continually appends document_view
to the path. My test case is a Folder with a Document in it called
index.html In this case:

         key = stack and stack[-1] or '(Default)'
         ti = self.getTypeInfo()
         path = ti and ti.getMethodPath(key) or None

key is always (Default) and path is always 'document_view'.

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.

I really need to sit down one day without the terrible head cold I have
now and see what you are actually trying to do.

Thanks.
-- 
   Andy McKay
   http://www.agmweb.ca





More information about the Zope-CMF mailing list