[z3-five] Bug in defaultView?

Richard Waid richard at iopen.net
Sun Oct 8 23:34:53 CEST 2006


On Sun, 2006-10-08 at 12:31 +0200, Lennart Regebro wrote:
> On 10/8/06, Richard Waid <richard at iopen.net> wrote:
> > This could be a bug, or it could be a misunderstanding of how
> > browser:defaultView is supposed to work in Five. I'm also using
> > Zope-2.9, so this may be 'fixed' in a later version of Five/Zope too.
> >
> > Ok, basically I want to have a defaultView of index.html on objects that
> > implement an index.html view, otherwise fallback to index_html.
> >
> > The __browser_default__ method in viewable.py/Viewable suggests that
> > this should be the behaviour (it has a fallback that says it falls back
> > to index_html),
> 
> Thats a documentation bug in that case.

More on this below.

> >   <browser:defaultView for=".interfaces.IGSContentFolder"
> >                        name="index.html"/>
> 
> Yes, that will make the default view index.html, thusly overridding
> the Zope2 default of index_html.

I'm thinking I wasn't clear enough. I understand that this
browser:defaultView directive means that for objects implementing
IGSContentFolder, index.html will be the default.

I'm not clear why:

  <five:defaultViewable class="OFS.Folder.Folder"/>

which is _required_ in the Zope-2.9 version of Five to let the
browser:defaultView directive work, also enforces 'index.html' as the
default (independently of the browser:defaultView directive). If it is
because the global defaultView for Five/Z3 is set to index.html ...
well, ok, but in that case why the code in viewable.py:

---
    def __browser_default__(self, request):
        obj = self
        path = None
        if request['REQUEST_METHOD'] not in ('GET', 'POST'):
            return obj, [request['REQUEST_METHOD']]
        try:
            obj, path = IBrowserDefault(self).defaultView(request)
        except ComponentLookupError:
            pass
        
        if path:
            if len(path) == 1 and path[0] == '__call__':
                return obj, ('fallback_call__',)
            return obj, path
        return self.__fallback_default__(request)
---

As far as I can tell, when the patch is in place (ie. when
five:defaultViewable is set for an object), the __fallback_default__ is
never called.

I realise this is probably irrelevant now, since it doesn't work like
this in Zope-2.10.


--Richard 



More information about the z3-five mailing list