[Zope-Checkins] SVN: Zope/branches/philikon-aq-and-__parent__/lib/python/Shared/DC/Scripts/Bindings.py Found and fixed the you_lose problem found during tests for the UnauthorizedBinding. We define our own __parent__ method on it now. See more explanation in the comment.

Hanno Schlichting plone at hannosch.info
Mon Jun 18 17:12:33 EDT 2007


Log message for revision 76770:
  Found and fixed the you_lose problem found during tests for the UnauthorizedBinding. We define our own __parent__ method on it now. See more explanation in the comment.
  

Changed:
  U   Zope/branches/philikon-aq-and-__parent__/lib/python/Shared/DC/Scripts/Bindings.py

-=-
Modified: Zope/branches/philikon-aq-and-__parent__/lib/python/Shared/DC/Scripts/Bindings.py
===================================================================
--- Zope/branches/philikon-aq-and-__parent__/lib/python/Shared/DC/Scripts/Bindings.py	2007-06-18 19:50:08 UTC (rev 76769)
+++ Zope/branches/philikon-aq-and-__parent__/lib/python/Shared/DC/Scripts/Bindings.py	2007-06-18 21:12:32 UTC (rev 76770)
@@ -175,19 +175,18 @@
     def __repr__(self):
         return '<UnauthorizedBinding: %s>' % self._name
 
+    def __parent__(self):
+        # Acquisition will nowadays try to do an getattr on all objects which
+        # aren't Acquisition wrappers asking for a __parent__ pointer. We need
+        # to provide a fake one, or our normal __getattr__ method will be used
+        # and fail as __parent__ starts with a __.
+        return None
+
     def __getattr__(self, name, default=None):
         # Make *extra* sure that the wrapper isn't used to access
         # __call__, etc.
         if name.startswith('__'):
-            if name == '__parent__':
-                # XXX For some reason the test in testBindings calls __parent__
-                # for bound_used_context_methodWithRoles_ps.
-                # I couldn't figure out why it tries that. So far it tried to
-                # call methodWithRoles twice. Now it's only called once and
-                # __parent__ is called the second time.
-                pass
-            else:
-                self.__you_lose()
+            self.__you_lose()
 
         return guarded_getattr(self._wrapped, name, default)
         #return getattr(self._wrapped, name, default)



More information about the Zope-Checkins mailing list