[Zope] TraversalError in custom TALES namespace during Five tests

Paul Winkler slinkp at gmail.com
Tue Dec 16 20:40:55 EST 2008

I've implemented a custom TALES namespace that works fine when tested
in the browser, but blows up in doctests.  Anybody seen behavior like

It appears that during the test, my adapter is looked up fine, but
later when we try to traverse to the method, we end up with a
zope.security._proxy._Proxy wrapper that hides the existence of my
methods. Just to reiterate, the same code *works fine* when
running Zope for real, and I only see this failure during tests.

 Here's the tail end of a test / pdb session:

 41  	    def traverse(self, name, furtherPath):
 42  ->	        subject = self._subject
 43  	        __traceback_info__ = (subject, name, furtherPath)
 44  	        attr = getattr(subject, name, _marker)
 45  	        if attr is not _marker:
 46  	            return attr
 47  	        if hasattr(subject, '__getitem__'):
(Pdb) n
> /home/pw/builds/slinktopp.openplans.org/builds/20081210/opencore/lib/zope/lib/python/zope/traversing/adapters.py(43)traverse()
-> __traceback_info__ = (subject, name, furtherPath)
(Pdb) n
> /home/pw/builds/slinktopp.openplans.org/builds/20081210/opencore/lib/zope/lib/python/zope/traversing/adapters.py(44)traverse()
-> attr = getattr(subject, name, _marker)
(Pdb) p subject
<opencore.tales.utils.OpencoreTales object at 0x9840510>
(Pdb) p name
(Pdb) p subject.member_title
*** AttributeError: <exceptions.AttributeError instance at 0x8a02518>

This appears to indicate that the OpencoreTales instance itself is fine,
but the security wrapper is preventing attribute access.

And here's my zcml:


  <content class=".utils.OpencoreTales">
    <require permission="zope2.View"
             attributes="setEngine pretty_date project_noun member_title" />

And here's the relevant part of the implementation:

class OpencoreTales(object):

    def __init__(self, context):
        import pdb; pdb.set_trace()
        self.context = context

    def member_title(self):
        return member_title(self.context)

Thanks for any advice,

- Paul Winkler


More information about the Zope mailing list