[Zope3-dev] ComponentLookupError while traversing
Marius Gedminas
mgedmin at b4net.lt
Sat Feb 12 15:38:22 EST 2005
Hi,
I've noticed the following message produced by a stripped-down Zope 3
instance:
.../Zope3/src/zope/app/traversing/adapters.py:188:
DeprecationWarning: A DefaultTraversable instance raised a NotFoundError
in traverse. Raising NotFoundError in this method is deprecated and
will no-longer be supported starting in ZopeX3 3.3. TraversalError
should be raised instead.
It was caused by a page template looking for an undefined menu.
traversePathElement from zope/app/traversing/adapters.py adapts a
MenuAccessView (from zope/app/publisher/browser/menu.py) to ITraversable
and gets a DefaultTraversable instace. DefaultTraversable.traverse
calls MenuAccessView.__getitem__ which calls zapi.getUtility, which in turn
raises ComponentLookupError. ComponentLookupError is a subclass of
NotFoundError, and it triggers a DeprecationWarning in traversePathElement.
I'd rather not see that warning, but I'm not sure what the correct solution is.
1. Should MenuAccessView.__getitem__ trap ComponentLookupError and raise
a KeyError instead?
or
2. Should traversePathElement consider ComponentLookupError to be a
special case and reraise it without showing a DeprecationWarning?
On a slightly related note, if I call
foo = traverseName(obj, name, default)
and obj[name] raises a KeyError, should traverseName return 'default',
or should it let the KeyError propagate?
Marius Gedminas
--
Gates' Law: Every 18 months, the speed of software halves.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20050212/69e346e6/attachment.bin
More information about the Zope3-dev
mailing list