[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Removed use of zapi, as this was causing import loops.

Jim Fulton jim at zope.com
Thu May 20 17:13:29 EDT 2004


Log message for revision 24842:

Removed use of zapi, as this was causing import loops.

Unfortunately, anything imported recursively from zapi can't safely
use it. :(



-=-
Modified: Zope3/trunk/src/zope/app/container/contained.py
===================================================================
--- Zope3/trunk/src/zope/app/container/contained.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/container/contained.py	2004-05-20 21:13:29 UTC (rev 24842)
@@ -25,7 +25,7 @@
 from zope.interface.declarations import ObjectSpecification
 from zope.interface import providedBy
 
-from zope.app import zapi
+from zope.app.exception.interfaces import UserError
 from zope.app.event.objectevent import ObjectEvent, modified
 from zope.app.event import publish
 from zope.app.i18n import ZopeMessageIDFactory as _
@@ -563,7 +563,7 @@
         "See zope.app.container.interfaces.INameChooser"
 
         if not name:
-            raise zapi.UserError(
+            raise UserError(
                 _("An empty name was provided. Names cannot be empty.")
                 )
 
@@ -573,12 +573,12 @@
             raise TypeError("Invalid name type", type(name))
 
         if name[:1] in '+@' or '/' in name:
-            raise zapi.UserError(
+            raise UserError(
                 _("Names cannot begin with '+' or '@' or contain '/'")
                 )
 
         if name in self.context:
-            raise zapi.UserError(
+            raise UserError(
                 _("The given name is already being used")
                 )
 

Modified: Zope3/trunk/src/zope/app/event/objectevent.py
===================================================================
--- Zope3/trunk/src/zope/app/event/objectevent.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/event/objectevent.py	2004-05-20 21:13:29 UTC (rev 24842)
@@ -26,7 +26,7 @@
 from zope.app.event.interfaces import ISubscriber
 from zope.interface import implements
 from zope.app.event import publish
-from zope.app import zapi
+from zope.component import subscribers
 
 _marker = object()
 
@@ -79,7 +79,7 @@
 
     def notify(self, event):
         assert IObjectEvent.providedBy(event)
-        adapters = zapi.subscribers((event.object, event), ISubscriber)
+        adapters = subscribers((event.object, event), ISubscriber)
         for adapter in adapters:
             adapter.notify(event)
 

Modified: Zope3/trunk/src/zope/app/site/servicecontainer.py
===================================================================
--- Zope3/trunk/src/zope/app/site/servicecontainer.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/site/servicecontainer.py	2004-05-20 21:13:29 UTC (rev 24842)
@@ -20,7 +20,6 @@
 
 from transaction import get_transaction
 from zope.app.container.contained import Contained
-from zope.app import zapi
 from zope.app.site.interfaces import IPossibleSite, ISite
 from zope.component.exceptions import ComponentLookupError
 from zope.component.interfaces import IServiceService

Modified: Zope3/trunk/src/zope/app/traversing/namespace.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/namespace.py	2004-05-20 15:01:27 UTC (rev 24841)
+++ Zope3/trunk/src/zope/app/traversing/namespace.py	2004-05-20 21:13:29 UTC (rev 24842)
@@ -17,7 +17,8 @@
 """
 import re
 import zope.interface
-from zope.app import zapi
+from zope import component
+from zope.component.servicenames import Presentation
 from zope.exceptions import NotFoundError
 from zope.app.traversing.interfaces import ITraversable
 from zope.proxy import removeAllProxies
@@ -94,9 +95,10 @@
        """
 
     if request is not None:
-        traverser = zapi.queryView(object, ns, request, providing=ITraversable)
+        traverser = component.queryView(object, ns, request,
+                                        providing=ITraversable)
     else:
-        traverser = zapi.queryNamedAdapter(object, ITraversable, ns)
+        traverser = component.queryNamedAdapter(object, ITraversable, ns)
 
     if traverser is None:
         raise NotFoundError("++%s++%s" % (ns, name))
@@ -156,7 +158,7 @@
     return resource
 
 def queryResourceInContext(ob, name, request, default=None):
-    resource_service = zapi.getService(ob, zapi.servicenames.Presentation)
+    resource_service = component.getService(ob, Presentation)
     resource = resource_service.queryResource(name, request)
     if resource is None:
         return default
@@ -326,7 +328,7 @@
 
     def traverse(self, name, ignored):
         """Used to traverse to an online help topic."""
-        return zapi.getService(self.context, 'OnlineHelp')
+        return component.getService(self.context, 'OnlineHelp')
 
 class view(object):
 
@@ -337,7 +339,7 @@
         self.request = request
     
     def traverse(self, name, ignored):
-        view = zapi.queryView(self.context, name, self.request)
+        view = component.queryView(self.context, name, self.request)
         if view is None:
             raise NotFoundError(self.context, name)
 




More information about the Zope3-Checkins mailing list