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

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
'member_title'
(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:

  <adapter
    for="*"
    provides="zope.traversing.interfaces.IPathAdapter"
    factory=".utils.OpencoreTales"
    name="opencore"
    trusted="true"
    />

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



And here's the relevant part of the implementation:

class OpencoreTales(object):
    component.adapts(interface.Interface)
    interface.implements(IPathAdapter)

    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

-- 
http://www.slinkp.com
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to