[Zope-Coders] Re: Changes to ZPublisher

Donovan Baarda abo at minkirri.apana.org.au
Wed Oct 6 22:34:23 EDT 2004


On Thu, 2004-10-07 at 12:11, Tres Seaver wrote:
> Richard Jones wrote:
[...]
> NotFound is an HTTP Protocol level mapping for an error;  it should 
> *not* be raised by application code.  In particular, __bobo_traverse__ 
> is called *both* by the publisher *and* by unrestrictedTraverse; 
> raising NotFound is *totally* unexpected and inappropriate for the 
> second case.  The current schizophrenia among its callers makes writing 
> a sane __bobo_traverse__ implementation logically impossible.
[...]

Hmmm. so much for NotFound... explains why I've never seen it used by
applications.

> The alternatives are:
> 
>    - As Sidnei proposed, have the publisher map {Attribute,Key}Errors
>      raised by __bobo_traverse__ onto NotFound, except when running in
>      debug mode.  Don't modify unrestrictedTraverse at all.

The fact that this is off in debug mode is good... I'm slowly being
converted into a +1 for AttributeError = 404.

I'm definitely still -1 for AttributeError in __bobo_traverse__ means
fallback to __getattr__, which was the second part of the branch.

>    - Define a special error, e.g. OFS.Traversable.Nonesuch, and make
>      raising it part of the contract for __bobo_traverse__;  raising
>      {Attribute,Key,Index,Value}Error from __bobo_traverse__ would then
>      be an unambiguous application error.  We should still decide what to
>      do about such errors, and should probably remove the publisher's
>      current DWIM (when it calls getattr / getitem directly).  The
>      downside here is having to modify the dozen or so __bobo_traverse__
>      implementations in the core, plus breaking uncountable third-party
>      implementations, for the sake of API purity.

too big a change. -1.

>    - Morph NotFound into a more generic exception, and make it part of
>      the contract (note that this is essentially identical to the
>      previous alternative, except for spelling).

Not sure... I think I agree that NotFound is for the publisher only, not
applications.

>    - Make returning 'None' for "not found" the contract for
>      __bobo_traverse__, and modify both the publisher and
>      unrestrictedTraverse to look for it.  Again, we would need to
>      revisit the core implementations, and risk breaking third-party
>      versions.
[...]

Does anyone currently really use and expect returning None to mean "no
docstring"?


-- 
Donovan Baarda <abo at minkirri.apana.org.au>
http://minkirri.apana.org.au/~abo/



More information about the Zope-Coders mailing list