[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - resources.py:1.12 viewmeta.py:1.38

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Mar 2 09:24:32 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv21657/src/zope/app/publisher/browser

Modified Files:
	resources.py viewmeta.py 
Log Message:


I originally added queryService() to ZAPI and this should have never been
done. Remove it and use getService() in the places where it was used instead.




=== Zope3/src/zope/app/publisher/browser/resources.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/publisher/browser/resources.py:1.11	Fri Nov 21 12:10:31 2003
+++ Zope3/src/zope/app/publisher/browser/resources.py	Tue Mar  2 09:24:31 2004
@@ -15,15 +15,14 @@
 
 $Id$
 """
-__metaclass__ = type # All classes are new style when run with Python 2.2+
-
 from zope.publisher.browser import BrowserView
 from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.component import getService
-from zope.app.services.servicenames import Presentation
 from zope.exceptions import NotFoundError
 from zope.interface import implements
+
+from zope.app import zapi
 from zope.app.location import locate
+from zope.app.services.servicenames import Presentation
 
 class Resources(BrowserView):
     """Provide a URL-accessible resource namespace
@@ -34,7 +33,7 @@
     def publishTraverse(self, request, name):
         '''See interface IBrowserPublisher'''
 
-        resource_service = getService(self, Presentation)
+        resource_service = zapi.getService(self, Presentation)
         resource = resource_service.queryResource(name, request)
         if resource is None:
             raise NotFoundError(self, name)
@@ -43,7 +42,7 @@
         return resource
 
     def browserDefault(self, request):
-        '''See interface IBrowserPublisher'''
+        '''See IBrowserPublisher'''
         return empty, ()
 
     def __getitem__(self, name):


=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.37 => 1.38 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.37	Wed Dec 17 10:37:27 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py	Tue Mar  2 09:24:31 2004
@@ -15,36 +15,26 @@
 
 $Id$
 """
-
 import os
 
-from zope.app import zapi
-from zope.interface import implements, classImplements, Interface
-from zope.publisher.interfaces.browser import IBrowserPublisher
-
-from zope.exceptions import NotFoundError
-
-from zope.security.checker import CheckerPublic, Checker
-from zope.security.checker import defineChecker
-
+from zope.component.exceptions import ComponentLookupError
 from zope.configuration.exceptions import ConfigurationError
+from zope.exceptions import NotFoundError
+from zope.interface import implements, classImplements, Interface
+from zope.publisher.interfaces.browser import \
+     IBrowserPublisher, IBrowserRequest, IBrowserPublisher
+from zope.security.checker import CheckerPublic, Checker, defineChecker
 
-from zope.app.services.servicenames import Interfaces
-
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IBrowserPublisher
-
-from zope.app.publisher.browser import BrowserView
-
+from zope.app import zapi
 from zope.app.component.metaconfigure import handler
-
 from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-
+from zope.app.publisher.browser import BrowserView
+from zope.app.publisher.browser.globalbrowsermenuservice import \
+     menuItemDirective, globalBrowserMenuService
 from zope.app.security.permission import checkPermission
+from zope.app.services.servicenames import Interfaces
 
-from zope.app.publisher.browser.globalbrowsermenuservice \
-     import menuItemDirective, globalBrowserMenuService
 
 # There are three cases we want to suport:
 #
@@ -104,9 +94,11 @@
          usage=u''
          ):
 
-    s = zapi.queryService(None, zapi.servicenames.Presentation)
-    if s is not None:
-        # on startup the service is not immediately there...
+    try:
+        s = zapi.getService(None, zapi.servicenames.Presentation)
+    except ComponentLookupError, err:
+        pass
+    else:
         s.useUsage(usage)
 
     _handle_menu(_context, menu, title, for_, name, permission)
@@ -285,9 +277,11 @@
                 # If no usage is declared explicitly for this page, use the
                 # usage given for the whole view.
                 usage = self.usage
-            s = zapi.queryService(None, zapi.servicenames.Presentation)
-            if s is not None:
-                # on startup the service is not immediately there...
+            try:
+                s = zapi.getService(None, zapi.servicenames.Presentation)
+            except ComponentLookupError, err:
+                pass
+            else:
                 s.useUsage(usage)
             if template:
                 cdict[pname] = ViewPageTemplateFile(template, usage=usage)




More information about the Zope3-Checkins mailing list