[Zope3-Users] Confused by ITraversable

Wade Leftwich wade at leftwich.us
Sat Dec 31 09:35:56 EST 2005


I guess I don't understand traversal at all.

I am trying to come up with the simplest possible class to exercise the
ITraversable interface. Here's what I have:

###
from zope.interface import implements
from zope.app.traversing.interfaces import ITraversable

class TravTestFlag(Exception):
    """Raise this flag when traverse() method gets called"""

class TravTest(object):
    implements(ITraversable)
    def traverse(self, name, furtherPath):
        raise TravTestFlag("traverse got called in TravTest with name
%s, furtherPath %s" % (name, furtherPath))
###

I hook it up to the ZMI with this configure.zcml:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="travtest"
    >

  <browser:addMenuItem
      class=".travtest.TravTest"
      title="Traversal Demo"
      permission="zope.ManageContent"
  />

</configure>

I create a TravTest object in my root folder with ID 'tt'.
Then I browse http://localhost:8080/tt/1/2/3. I get a stock 404 error,
which I guess means that TraversalError is getting raised someplace
besides inside my traverse() method. I really expected to see a
TravTestFlag.


Any hints appreciated.

-- Wade Leftwich
Ithaca, NY





More information about the Zope3-users mailing list