[Zope3-checkins] CVS: Zope3/src/zope/app/publication - zopepublication.py:1.43

Philipp von Weitershausen philikon at philikon.de
Sun Mar 21 12:00:17 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/publication
In directory cvs.zope.org:/tmp/cvs-serv16455/src/zope/app/publication

Modified Files:
	zopepublication.py 
Log Message:
Try to get a location even if the traversed object is an instance method.
It doesn't work always (as for resources, for example), but it works for
what we're interested in: undo log.


=== Zope3/src/zope/app/publication/zopepublication.py 1.42 => 1.43 ===
--- Zope3/src/zope/app/publication/zopepublication.py:1.42	Sat Mar 20 08:37:45 2004
+++ Zope3/src/zope/app/publication/zopepublication.py	Sun Mar 21 11:59:44 2004
@@ -17,6 +17,7 @@
 """
 import sys
 import logging
+from new import instancemethod
 
 from ZODB.POSException import ConflictError
 
@@ -28,6 +29,7 @@
 
 from zope.security.management import newSecurityManager
 from zope.security.checker import ProxyFactory
+from zope.security.proxy import trustedRemoveSecurityProxy
 from zope.proxy import removeAllProxies
 from zope.exceptions import Unauthorized
 
@@ -134,7 +136,7 @@
         request.hold(cleanup)  # Close the connection on request.close()
 
         self.openedConnection(conn)
-##        conn.setDebugInfo(getattr(request, 'environ', None), request.other)
+        #conn.setDebugInfo(getattr(request, 'environ', None), request.other)
 
         root = conn.root()
         app = root.get(self.root_name, None)
@@ -161,12 +163,26 @@
         """
         txn.setUser(request.user.id)
 
+        # Work around methods that are usually used for views
+        bare = trustedRemoveSecurityProxy(ob)
+        if isinstance(bare, instancemethod):
+            ob = bare.im_self
+
         # set the location path
         path = None
         locatable = IPhysicallyLocatable(ob, None)
         if locatable is not None:
-            path = locatable.getPath()
-        txn.setExtendedInfo('location', path)
+            # Views are made children of their contexts, but that
+            # doesn't necessarily mean that we can fully resolve the
+            # path. E.g. the family tree of a resource cannot be
+            # resolved completely, as the presentation service is a
+            # dead end.
+            try:
+                path = locatable.getPath()
+            except AttributeError:
+                pass
+        if path is not None:
+            txn.setExtendedInfo('location', path)
 
         # set the request type
         iface = IRequest




More information about the Zope3-Checkins mailing list