[Zope-dev] traversal: different with and without a request

Christian Theune ct at gocept.com
Wed Oct 15 15:35:23 EDT 2008


On Wed, 2008-10-15 at 20:34 +0200, Dieter Maurer wrote:
> Christian Theune wrote at 2008-10-15 17:42 +0200:
> >we stumbled over an annoyance that took a while to debug:
> >
> >Writing an ITraversable, we used zope.traversing.api.traverse() in a
> >test to verify our code. We registered the ITraversable as an
> >(non-multi) adapter and ended up with a working test.
> >
> >In the actual system, we found that the traversable would not be used.
> >After investigation we found a conditional branch in the traverse()
> >function which would look for a multi-adapter if a request was around,
> >and a regular adapter if not.
> >
> >We didn't anticipate this difference and it cost us some time, so we
> >wonder whether this has to be the way it is, or whether this could be
> >changed to behave more obvious and consistent.
> 
> The request may have important information to control traversal, e.g.
> a layer. On the other hand, when no request is available (e.g. in a
> script), you cannot use one. Thus, the current behaviour may cover
> useful use cases.

I'm not arguing that the behaviour wouldn't be useful in some cases, I'm
just arguing it's not obvious. Philipp's pointer to the whole area being
messy is correct. This might be a good sprint topic.

> Maybe, you should not trust your tests stupidly -- unless they emulate
> the actual system sufficently ;-)

I only found this because I'm not trusting my tests blindly and I both
tested automatically and manually to verify that the test actually does
test what I want. ;)

Christian

-- 
Christian Theune · ct at gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1
Zope and Plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20081015/afba8acc/attachment.bin 


More information about the Zope-Dev mailing list