[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zope3-users
Subject:    [Zope3-Users] Confused by ITraversable
From:       Wade Leftwich <wade () leftwich ! us>
Date:       2005-12-31 14:35:56
Message-ID: 43B6974C.4070403 () leftwich ! us
[Download RAW message or body]

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



_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic