[Zope-dev] Re: default view

Tres Seaver tseaver at palladion.com
Thu Jun 22 08:43:34 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Philipp von Weitershausen wrote:
> Dieter Maurer wrote:
>> Florent Guillaume wrote at 2006-6-18 02:05 +0200:
>>> ...
>>>             if hasattr(object,'__bobo_traverse__'):
>>>                 subobject=object.__bobo_traverse__(request, name)
>> If you are working on it, then you should implement a
>> means that "__bobo_traverse__" can tell the caller that
>> it should use the normal default.
>>
>> This feature makes lots of "__bobo_traverse__" implementations
>> much saner. A prominent example is the Archetypes' one.
>>
>>
>> In our private Zope version, I have used an exception
>> ("UseTraversalDefault") for this purpose.
> 
> I think that __bobo_traverse__ can raise AttributeError currently to
> indicate that it has failed to look up an attribute and that traversal
> should try other options. Apart from being a more explicit spelling,
> what advantage would UseTraversalDefault have?

The contract for '__bobo_traverse__' is actually insane on this point,
becuase it has to serve two "masters":

  - In publishing traversal, an AttributeErrror raised from
    '__bobo_traverse__' has the semantics you describe.

  - In '{un,}restrictedTraverse', an AtttributeError causes the whole
    traversal process to abort, returning the 'default' value (if
    passed), or raising.

Fixing this incompatibility without breaking applications which may be
unknowingling dependent on it is going to be hard.


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEmpB2+gerLs4ltQ4RAtc9AKDIxupDiJI57PA2+Vsx/HNDHBlMWgCgosXm
BCH//4dbeBOKt/C6ESsEvG0=
=4DH2
-----END PGP SIGNATURE-----


More information about the Zope-Dev mailing list