[Zope3-checkins] CVS: Zope3/src/zope/app/publication - publicationtraverse.py:1.11 xmlrpc.py:1.8 zopepublication.py:1.35

Jim Fulton jim at zope.com
Sun Sep 21 13:32:28 EDT 2003


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

Modified Files:
	publicationtraverse.py xmlrpc.py zopepublication.py 
Log Message:
No-longer use context wrappers.


=== Zope3/src/zope/app/publication/publicationtraverse.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/publication/publicationtraverse.py:1.10	Fri Jun 20 02:45:08 2003
+++ Zope3/src/zope/app/publication/publicationtraverse.py	Sun Sep 21 13:31:56 2003
@@ -19,7 +19,6 @@
 from zope.component import queryView
 from zope.publisher.interfaces import NotFound
 from types import StringTypes
-from zope.app.context import ContextWrapper
 from zope.security.checker import ProxyFactory
 
 from zope.proxy import removeAllProxies
@@ -80,7 +79,7 @@
             else:
                 raise NotFound(ob, name, request)
 
-        return ProxyFactory(ContextWrapper(ob2, ob, name=name))
+        return ProxyFactory(ob2)
 
 class PublicationTraverser(PublicationTraverse):
 


=== Zope3/src/zope/app/publication/xmlrpc.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/publication/xmlrpc.py:1.7	Mon Aug  4 19:19:04 2003
+++ Zope3/src/zope/app/publication/xmlrpc.py	Sun Sep 21 13:31:56 2003
@@ -17,7 +17,6 @@
 
 $Id$
 """
-from zope.app.context import ContextWrapper
 from zope.app.publication.zopepublication import ZopePublication
 from zope.component import queryView, queryDefaultViewName
 from zope.proxy import removeAllProxies
@@ -55,15 +54,15 @@
             view_name = view_name[2:]
 
         # If ob is a presentation object, then we just get the method
-        if IXMLRPCPresentation.isImplementedBy(naked_ob) and \
-               hasattr(ob, view_name):
-            return ProxyFactory(
-                ContextWrapper(getattr(ob, view_name), ob, name=view_name))
+        if (IXMLRPCPresentation.isImplementedBy(naked_ob) and 
+            hasattr(ob, view_name)
+            ):
+            return ProxyFactory(getattr(ob, view_name))
 
         # Let's check whether name could be a view 
         view = queryView(ob, view_name, request)
         if view is not None:
-            return ProxyFactory(ContextWrapper(view, ob, name=view_name))
+            return ProxyFactory(view)
 
         # Now let's see whether we have a default view with a matching method
         # name
@@ -72,8 +71,7 @@
         if defaultName is not None:
             view = queryView(ob, defaultName, request, object)
             if hasattr(view, view_name):
-                return ProxyFactory(ContextWrapper(getattr(view, view_name), ob,
-                                                   name=view_name))
+                return ProxyFactory(getattr(view, view_name))
 
         # See whether we have a subobject
         return super(XMLRPCPublication, self).traverseName(request, ob, name)


=== Zope3/src/zope/app/publication/zopepublication.py 1.34 => 1.35 ===
--- Zope3/src/zope/app/publication/zopepublication.py:1.34	Tue Sep  2 16:46:48 2003
+++ Zope3/src/zope/app/publication/zopepublication.py	Sun Sep 21 13:31:56 2003
@@ -26,8 +26,6 @@
 from zope.security.management import newSecurityManager
 from zope.security.checker import ProxyFactory
 
-from zope.app.context import ContextWrapper
-
 from zope.proxy import removeAllProxies
 
 from zope.app.interfaces.services.service import ISite
@@ -44,11 +42,11 @@
 
 from zope.app.publication.publicationtraverse import PublicationTraverse
 
-from zope.app.context import ContextWrapper
-
 # XXX Should this be imported here?
 from transaction import get_transaction
 
+from zope.app.location import LocationProxy
+
 class Cleanup(object):
     def __init__(self, f):
         self._f = f
@@ -75,7 +73,7 @@
             if p is None:
                 raise Unauthorized # If there's no default principal
 
-        request.setUser(ContextWrapper(p, prin_reg))
+        request.setUser(p)
         newSecurityManager(request.user)
         get_transaction().begin()
 
@@ -90,8 +88,7 @@
             return
 
         sm = removeAllProxies(ob).getSiteManager()
-        sm = ContextWrapper(sm, ob, name="++etc++site")
-
+        
         auth_service = sm.queryService(Authentication)
         if auth_service is None:
             # No auth service here
@@ -105,7 +102,7 @@
                 # nothing to do here
                 return
 
-        request.setUser(ContextWrapper(principal, auth_service))
+        request.setUser(principal)
         newSecurityManager(request.user)
 
 
@@ -149,7 +146,7 @@
         if app is None:
             raise SystemError, "Zope Application Not Found"
 
-        return ProxyFactory(ContextWrapper(app, None))
+        return ProxyFactory(app)
 
     def callObject(self, request, ob):
         return mapply(ob, request.getPositionalArguments(), request)
@@ -233,10 +230,26 @@
                 request, 'application error-handling')
             view = None
             try:
-                exception = ContextWrapper(exc_info[1], object)
-                name = queryDefaultViewName(exception, request)
+
+                # XXX we need to get a location. The object might not
+                # have one, because it might be a method. If we don't
+                # have a parent attr but to have an im_self or an
+                # __self__, use that:
+
+                loc = object
+                if hasattr(object, '__parent__'):
+                    loc = object
+                else:
+                    loc = removeAllProxies(object)
+                    loc = getattr(loc, 'im_self', loc)
+                    if loc is loc:
+                        loc = getattr(loc, '__self__', loc)
+                    loc = ProxyFactory(loc)
+                
+                exception = LocationProxy(exc_info[1], loc)
+                name = queryDefaultViewName(exception, request, context=object)
                 if name is not None:
-                    view = queryView(exception, name, request)
+                    view = queryView(exception, name, request, context=object)
             except:
                 # Problem getting a view for this exception. Log an error.
                 tryToLogException(




More information about the Zope3-Checkins mailing list