[Zope3-checkins] CVS: Zope3/src/zope/app/component - hooks.py:1.11.2.1 nextservice.py:1.7.2.1

Jim Fulton jim at zope.com
Mon Sep 8 15:22:05 EDT 2003


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

Modified Files:
      Tag: parentgeddon-branch
	hooks.py nextservice.py 
Log Message:
Checking in work in progress on parentgeddon-branch so Fred can help
me to get the tests passing.  Specific log entries will be provided
when we merge this into the head.


=== Zope3/src/zope/app/component/hooks.py 1.11 => 1.11.2.1 ===
--- Zope3/src/zope/app/component/hooks.py:1.11	Tue Sep  2 16:46:45 2003
+++ Zope3/src/zope/app/component/hooks.py	Mon Sep  8 14:21:34 2003
@@ -21,76 +21,17 @@
 from zope.component.exceptions import ComponentLookupError
 from zope.component.servicenames import Adapters
 from zope.app.interfaces.services.service import ISite
-from zope.app.context import ContextWrapper
-from zope.context import getWrapperContainer, isWrapper, getWrapperData
 from zope.component.service import serviceManager
 from zope.proxy import removeAllProxies
 from zope.security.proxy import trustedRemoveSecurityProxy
 from zope.app.traversing import IContainmentRoot
 
-## alog=open('alog','w')
-## slog=open('slog','w')
-## swlog=open('swlog','w')
-## sulog=open('sulog','w')
-## sutblog=open('sutblog','w')
-## nlog=open('nlog','w')
-
-## import sys, traceback
-
-
-
 
 def getServiceManager_hook(context, local=False, recurse=False):
 
-    
-    # XXX Uh, there's this special case for context being none. :(
     if context is None:
-##         if not recurse:
-##             slog.write('n')
-##             nlog.write('\n')
-##             f = sys._getframe(1)
-##             nlog.write("%s\n" % context.__class__)
-##             nlog.write(''.join(traceback.format_stack(sys._getframe(1),
-##                                                          5)))
-##             nlog.write("\n")
-
         return serviceManager
 
-
-    data = None
-    wrapped = isWrapper(context)
-    if wrapped:
-        data = getWrapperData(context, create=True)
-##         unwrapped = removeAllProxies(context)
-##         oid = id(unwrapped)
-##         did = id(data)
-##         if not recurse:
-##             swlog.write("%s %s %s\n" %
-##                         (context.__class__.__name__, oid, did))
-        cached = data.get('zope.app.component.hooks.sm')
-        if cached is not None:
-##             if not recurse:
-##                 slog.write('h')
-            return cached
-##         else:
-##             if not recurse:
-##                 slog.write('m')
-##     else:
-##         if not recurse:
-##             sulog.write("%s.%s\n" %
-##                         (context.__class__.__module__,
-##                          context.__class__.__name__))
-##             f = sys._getframe(1)
-##             avoid = "src/zope/app/component/hooks.py"
-##             if (1 or f.f_back.f_code.co_filename != avoid
-##                 ):
-##                 sutblog.write("%s\n" % context.__class__)
-##                 sutblog.write(''.join(traceback.format_stack(sys._getframe(1),
-##                                                              5)))
-##                 sutblog.write("\n")
-##             slog.write('u')
-        
-
     clean_context = removeAllProxies(context)
 
     # if the context is actually a service or service manager...
@@ -98,13 +39,9 @@
         sm = trustedRemoveSecurityProxy(context)
 
     elif (ISite.isImplementedBy(clean_context)):
-        sm = ContextWrapper(
-            trustedRemoveSecurityProxy(context.getSiteManager()),
-            context,
-            name="++etc++site",
-            )
+        return context.getSiteManager()
     else:
-        container = getWrapperContainer(context)
+        container = getattr(context, '__parent__', None)
         if container is None:
             if local:
                 # Check to make sure that when we run out of context, we
@@ -120,40 +57,17 @@
             # don't have a service manager, so try again, recursively:
             sm = getServiceManager_hook(container, local, True)
 
-    # Now cache what we found, cause we might look for it again:
-    if wrapped:
-        data['zope.app.component.hooks.sm'] = sm
-
     return sm
 
 def queryNamedAdapter(object, interface, name, default=None, context=None):
     if context is None:
         context = object
 
-    wrapped = isWrapper(context)
-##     alog.write("%s %s.%s %s.%s\n" % (wrapped,
-##                                context.__class__.__module__,
-##                                context.__class__.__name__,
-##                                interface.__module__,
-##                                interface.getName(),
-##                                ))
-    if wrapped:
-        data = getWrapperData(context, create=True)
-        adapters = data.get('zope.app.component.hooks.adapters')
-        if adapters is None:
-            try:
-                adapters = getService(context, Adapters)
-            except ComponentLookupError:
-                # Oh blast, no adapter service. We're probably just
-                # running from a test
-                return default
-            data['zope.app.component.hooks.adapters'] = adapters
-    else:
-        try:
-            adapters = getService(context, Adapters)
-        except ComponentLookupError:
-            # Oh blast, no adapter service. We're probably just
-            # running from a test
-            return default
+    try:
+        adapters = getService(context, Adapters)
+    except ComponentLookupError:
+        # Oh blast, no adapter service. We're probably just
+        # running from a test
+        return default
 
     return adapters.queryNamedAdapter(object, interface, name, default)


=== Zope3/src/zope/app/component/nextservice.py 1.7 => 1.7.2.1 ===
--- Zope3/src/zope/app/component/nextservice.py:1.7	Tue Sep  2 16:46:45 2003
+++ Zope3/src/zope/app/component/nextservice.py	Mon Sep  8 14:21:34 2003
@@ -18,7 +18,6 @@
 
 from zope.component.exceptions import ComponentLookupError
 from zope.component.service import serviceManager
-from zope.context import getWrapperContainer
 from zope.proxy import removeAllProxies
 from zope.app.interfaces.services.service import ISite
 from zope.app.component.hooks import getServiceManager_hook
@@ -59,20 +58,20 @@
 
     # get the service manager container, which ought to be the context
     # contaioner.
-    container = getWrapperContainer(sm)
+    container = sm.__parent__
 
     # But we're *really* paranoid, so we'll double check.
     while ((container is not None) and not
            ISite.isImplementedBy(removeAllProxies(container))
            ):
-        container = getWrapperContainer(container) # we should be
+        container = container.__parent__ # we should be
 
     # Now we need to step up so we can look for a service manager above.
-    context = getWrapperContainer(container)
+    context = getattr(container, '__parent__', None)
 
     # But we have to make sure we haven't got the same object..
     while (context is not None) and (context == container):
-        context = getWrapperContainer(context)
+        context = context.__parent__
 
     if context is None:
         return serviceManager




More information about the Zope3-Checkins mailing list