[Zope-Coders] Changes to ZPublisher

Chris McDonough chrism at plope.com
Wed Oct 6 12:29:55 EDT 2004


On Wed, 2004-10-06 at 10:00, Sidnei da Silva wrote:
> Hello,
> 
> I've made some changes on the way ZPublisher deals with
> __bobo_traverse__. 
> 
> Here's the branch:
> svn+ssh://svn.zope.org/repos/main/Zope/branches/dc-bobo_traverse-branch
> 
> Before the changes, exceptions on __bobo_traverse__ would not be
> handled, so if a AttributeError would happen, it would pop up
> untouched, resulting on a 500 response status, instead of 404.

Why is that a good thing?  Shouldn't it be up to the implementor to
decide what should happen during bobo traverse?  If an exception happens
that raises AttributeError or KeyError during __bt__, I don't think I
want it to try something else.

> It would also try __bobo_traverse__ only, if __bobo_traverse__ exists,
> completely ignoring __getattr__ and __getitem__.


What makes it desirable to use __getattr__ and/or __getitem__ if the
object has a __bobo_traverse__?

> After my change, AttributeError and KeyError in __bobo_traverse__
> will be converted to a NotFound, resulting in a 404 response status.

This seems like a bit more DWIM that would need to be carefully
undocumented, like all the other DWIM. ;-)

> It will also continue looking through __getattr__ and __getitem__,
> which is where the semantics really differ. I'm more worried about
> changing the semantincs because there are other places where
> __bobo_traverse__ is used, namely restrictedTravers on OFS.Traversable
> and PageTemplates.Expressions.

I don't know if this is a win.

> 
> This change would simplify the implementations of __bobo_traverse__,
> which would not have to worry about looking at __getattr__ and
> __getitem__ themselves, but I would like to know what people think
> first.

I'm -1, FWIW.

- C




More information about the Zope-Coders mailing list