[Zope3-checkins] SVN: Zope3/branches/3.3/src/zope/app/apidoc/ Remove zapi imports from zope.apidoc package.

Florent Xicluna laxyf at yahoo.fr
Thu Sep 7 05:08:18 EDT 2006


Log message for revision 70020:
  Remove zapi imports from zope.apidoc package.
  Use zope.component, zope.traversing and zope.security.proxy imports.

Changed:
  U   Zope3/branches/3.3/src/zope/app/apidoc/bookmodule/book.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/browser/preference.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/classregistry.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/README.txt
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/class_.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/function.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/introspector.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/menu.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/module.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/zcml.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/codemodule.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/directives.txt
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/interfaces.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/codemodule/zcml.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/component.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/disabled.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/browser.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/ifacemodule.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/presentation.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/typemodule/browser.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/utilities.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/utilitymodule/browser.py
  U   Zope3/branches/3.3/src/zope/app/apidoc/zcmlmodule/browser.py

-=-
Modified: Zope3/branches/3.3/src/zope/app/apidoc/bookmodule/book.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/bookmodule/book.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/bookmodule/book.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -23,12 +23,11 @@
 __docformat__ = 'restructuredtext'
 import os.path
 
-import zope.app.apidoc.bookmodule
-from zope.app import zapi
 from zope.interface import implements
+
+import zope.app.apidoc.bookmodule
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.i18n import ZopeMessageFactory as _
-
 from zope.app.onlinehelp.onlinehelp import OnlineHelp
 
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/browser/preference.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/browser/preference.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/browser/preference.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -18,8 +18,8 @@
 __docformat__ = "reStructuredText"
 
 from zope.publisher.browser import applySkin
+from zope.traversing.api import getRoot
 
-from zope.app import zapi
 from zope.app.apidoc.browser.skin import APIDOC
 from zope.app.tree.browser.cookie import CookieTreeView
 from zope.app.preference.browser import PreferenceGroupFilter
@@ -29,7 +29,7 @@
     """Preferences Tree using the stateful cookie tree."""
 
     def apidocTree(self):
-        root = zapi.getRoot(self.context)['apidoc']
+        root = getRoot(self.context)['apidoc']
         filter = PreferenceGroupFilter()
         return self.cookieTree(root, filter)
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/classregistry.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/classregistry.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/classregistry.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -25,8 +25,6 @@
 
 import sys
 
-from zope.app import zapi
-
 class ClassRegistry(dict):
     """A simple registry for classes."""
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/README.txt
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/README.txt	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/README.txt	2006-09-07 09:08:16 UTC (rev 70020)
@@ -9,9 +9,9 @@
 
 We will also need the code browser documentation module:
 
-  >>> from zope.app import zapi
+  >>> from zope.component import getUtility
   >>> from zope.app.apidoc.interfaces import IDocumentationModule
-  >>> cm = zapi.getUtility(IDocumentationModule, 'Code')
+  >>> cm = getUtility(IDocumentationModule, 'Code')
 
 The `zope` package is already registered and available with the code module.
 
@@ -22,8 +22,9 @@
 The module details are easily created, since we can just use the traversal
 process to get a module documentation object:
 
+  >>> from zope.traversing.api import traverse
   >>> details = browser.module.ModuleDetails(None, None)
-  >>> details.context = zapi.traverse(cm,
+  >>> details.context = traverse(cm,
   ...     'zope/app/apidoc/codemodule/codemodule')
   >>> from zope.publisher.browser import TestRequest
   >>> details.request = TestRequest()
@@ -84,7 +85,7 @@
 process to get a class documentation object:
 
   >>> details = browser.class_.ClassDetails()
-  >>> details.context = zapi.traverse(
+  >>> details.context = traverse(
   ...     cm, 'zope/app/apidoc/codemodule/codemodule/CodeModule')
 
   >>> details.request = TestRequest()
@@ -199,7 +200,7 @@
 documentation component:
 
   >>> details = browser.function.FunctionDetails()
-  >>> details.context = zapi.traverse(cm,
+  >>> details.context = traverse(cm,
   ...     'zope/app/apidoc/codemodule/browser/tests/foo')
   >>> details.request = TestRequest()
 
@@ -244,7 +245,7 @@
 documentation component:
 
   >>> details = browser.text.TextFileDetails()
-  >>> details.context = zapi.traverse(cm,
+  >>> details.context = traverse(cm,
   ...     'zope/app/apidoc/codemodule/README.txt')
   >>> details.request = TestRequest()
 
@@ -267,7 +268,7 @@
 provide all the view content:
 
   >>> details = browser.zcml.DirectiveDetails()
-  >>> zcml = zapi.traverse(cm,
+  >>> zcml = traverse(cm,
   ...     'zope/app/apidoc/codemodule/configure.zcml')
   >>> details.context = zcml.rootElement
   >>> details.request = TestRequest()

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/class_.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/class_.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/class_.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -19,11 +19,13 @@
 
 import inspect
 import types
+from zope.component import getUtility
 from zope.proxy import removeAllProxies
 from zope.security.proxy import removeSecurityProxy
+from zope.traversing.api import getParent, traverse
+from zope.traversing.browser import absoluteURL
 from zope.traversing.interfaces import TraversalError
 
-from zope.app import zapi
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.utilities import getPythonPath, getPermissionIds
 from zope.app.apidoc.utilities import renderText, getFunctionSignature
@@ -61,7 +63,7 @@
     def _listClasses(self, classes):
         """Prepare a list of classes for presentation."""
         info = []
-        codeModule = zapi.getUtility(IDocumentationModule, "Code")
+        codeModule = getUtility(IDocumentationModule, "Code")
         for cls in classes:
             # We need to removeAllProxies because the security checkers for
             # zope.app.container.contained.ContainedProxy and
@@ -71,8 +73,8 @@
             path = getPythonPath(unwrapped_cls)
             url = None
             try:
-                klass = zapi.traverse(codeModule, path.replace('.', '/'))
-                url = zapi.absoluteURL(klass, self.request)
+                klass = traverse(codeModule, path.replace('.', '/'))
+                url = absoluteURL(klass, self.request)
             except TraversalError:
                 # If one of the classes is implemented in C, we will not
                 # be able to find it.
@@ -83,8 +85,8 @@
 
     def getBaseURL(self):
         """Return the URL for the API Documentation Tool."""
-        m = zapi.getUtility(IDocumentationModule, "Code")
-        return zapi.absoluteURL(zapi.getParent(m), self.request)
+        m = getUtility(IDocumentationModule, "Code")
+        return absoluteURL(getParent(m), self.request)
 
 
     def getInterfaces(self):
@@ -145,5 +147,5 @@
     def getDoc(self):
         """Get the doc string of the class STX formatted."""
         return renderText(self.context.getDocString() or '',
-                          zapi.getParent(self.context).getPath())
+                          getParent(self.context).getPath())
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/function.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/function.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/function.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -16,7 +16,10 @@
 $Id: browser.py 29143 2005-02-14 22:43:16Z srichter $
 """
 __docformat__ = 'restructuredtext'
-from zope.app import zapi
+from zope.component import getUtility
+from zope.traversing.api import getParent
+from zope.traversing.browser import absoluteURL
+
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.utilities import renderText
 
@@ -28,7 +31,7 @@
     def getDocString(self):
         """Get the doc string of the function in a rendered format."""
         return renderText(self.context.getDocString() or '',
-                          zapi.getParent(self.context).getPath())
+                          getParent(self.context).getPath())
 
 
     def getAttributes(self):
@@ -43,5 +46,5 @@
 
     def getBaseURL(self):
         """Return the URL for the API Documentation Tool."""
-        m = zapi.getUtility(IDocumentationModule, "Code")
-        return zapi.absoluteURL(zapi.getParent(m), self.request)
+        m = getUtility(IDocumentationModule, "Code")
+        return absoluteURL(getParent(m), self.request)

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/introspector.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/introspector.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/introspector.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -27,8 +27,9 @@
 from zope.traversing.interfaces import IPhysicallyLocatable, IContainmentRoot
 from zope.location import location
 from zope.publisher.browser import BrowserView
+from zope.traversing.api import getParent, traverse
 
-from zope.app import zapi, apidoc
+from zope.app import apidoc
 
 def getTypeLink(type):
     if type is types.NoneType:
@@ -104,14 +105,14 @@
         # it back.
         direct = list(directlyProvidedBy(request))
 
-        self.klassView = zapi.traverse(
+        self.klassView = traverse(
             TraversalRoot(),
             '/++apidoc++/Code/%s/@@index.html' %path, request=request)
 
         directlyProvides(request, direct)
 
     def parent(self):
-        return zapi.getParent(self.context)
+        return getParent(self.context)
 
     def getBaseURL(self):
         return self.klassView.getBaseURL()
@@ -177,7 +178,7 @@
                 'signature': signature,
                 'doc': apidoc.utilities.renderText(
                      val.__doc__ or '',
-                     zapi.getParent(self.klassView.context).getPath()),
+                     getParent(self.klassView.context).getPath()),
                 'interface': apidoc.utilities.getInterfaceForAttribute(
                      name, klass._Class__all_ifaces)}
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/menu.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/menu.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/menu.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -16,7 +16,10 @@
 $Id: browser.py 29143 2005-02-14 22:43:16Z srichter $
 """
 __docformat__ = 'restructuredtext'
-from zope.app import zapi
+from zope.component import getUtility
+from zope.traversing.api import traverse
+from zope.traversing.browser import absoluteURL
+
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.classregistry import classRegistry
 
@@ -31,11 +34,11 @@
         """Find the classes that match a partial path.
 
         Examples::
-          >>> from zope.app import zapi
+          >>> from zope.component import getUtility
           >>> from zope.app.apidoc.codemodule.class_ import Class
           >>> from zope.app.apidoc.interfaces import IDocumentationModule
 
-          >>> cm = zapi.getUtility(IDocumentationModule, 'Code')
+          >>> cm = getUtility(IDocumentationModule, 'Code')
           >>> mod = cm['zope']['app']['apidoc']['codemodule']['browser']
 
           Setup a couple of classes and register them.
@@ -85,14 +88,14 @@
         path = self.request.get('path', None)
         if path is None:
             return []
-        classModule = zapi.getUtility(IDocumentationModule, "Code")
+        classModule = getUtility(IDocumentationModule, "Code")
         results = []
         for p in classRegistry.keys():
             if p.find(path) >= 0:
-                klass = zapi.traverse(classModule, p.replace('.', '/'))
+                klass = traverse(classModule, p.replace('.', '/'))
                 results.append(
                     {'path': p,
-                     'url': zapi.absoluteURL(klass, self.request) + '/'
+                     'url': absoluteURL(klass, self.request) + '/'
                      })
         results.sort(lambda x, y: cmp(x['path'], y['path']))
         return results
@@ -102,12 +105,12 @@
         """Find all classes
 
         Examples::
-          >>> from zope.app import zapi
+          >>> from zope.component import getUtility
           >>> from zope.app.apidoc.codemodule.class_ import Class
           >>> from zope.app.apidoc.interfaces import IDocumentationModule
 
 
-          >>> cm = zapi.getUtility(IDocumentationModule, 'Code')
+          >>> cm = getUtility(IDocumentationModule, 'Code')
           >>> mod = cm['zope']['app']['apidoc']['codemodule']['browser']
 
           Setup a couple of classes and register them.
@@ -137,15 +140,15 @@
           >>> len(info) > 3
           True
         """
-        classModule = zapi.getUtility(IDocumentationModule, "Code")
+        classModule = getUtility(IDocumentationModule, "Code")
         classModule.setup() # run setup if not yet done
         results = []
         counter = 0
         for p in classRegistry.keys():
-            klass = zapi.traverse(classModule, p.replace('.', '/'))
+            klass = traverse(classModule, p.replace('.', '/'))
             results.append(
                 {'path': p,
-                 'url': zapi.absoluteURL(klass, self.request),
+                 'url': absoluteURL(klass, self.request),
                  'counter': counter
                  })
             counter += 1

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/module.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/module.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/module.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -16,12 +16,14 @@
 $Id: browser.py 29143 2005-02-14 22:43:16Z srichter $
 """
 __docformat__ = 'restructuredtext'
+from zope.component import getMultiAdapter
 from zope.interface.interface import InterfaceClass
-from zope.security.proxy import removeSecurityProxy
 from zope.proxy import removeAllProxies
 from zope.publisher.browser import BrowserView
+from zope.security.proxy import isinstance, removeSecurityProxy
+from zope.traversing.api import getName, getParent
+from zope.traversing.browser import absoluteURL
 
-from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
 
 from zope.app.apidoc.apidoc import APIDocumentation
@@ -33,9 +35,9 @@
 from zope.app.apidoc.codemodule.zcml import ZCMLFile
 
 def findAPIDocumentationRoot(obj, request):
-    if zapi.isinstance(obj, APIDocumentation):
-        return zapi.absoluteURL(obj, request)
-    return findAPIDocumentationRoot(zapi.getParent(obj), request)
+    if isinstance(obj, APIDocumentation):
+        return absoluteURL(obj, request)
+    return findAPIDocumentationRoot(getParent(obj), request)
 
 
 class ModuleDetails(BrowserView):
@@ -64,14 +66,14 @@
         entries = [{'name': name,
                     # only for interfaces; should be done differently somewhen
                     'path': getPythonPath(removeAllProxies(obj)),
-                    'url': zapi.absoluteURL(obj, self.request),
-                    'ismodule': zapi.isinstance(obj, Module),
-                    'isinterface': zapi.isinstance(
+                    'url': absoluteURL(obj, self.request),
+                    'ismodule': isinstance(obj, Module),
+                    'isinterface': isinstance(
                          removeAllProxies(obj), InterfaceClass),
-                    'isclass': zapi.isinstance(obj, Class),
-                    'isfunction': zapi.isinstance(obj, Function),
-                    'istextfile': zapi.isinstance(obj, TextFile),
-                    'iszcmlfile': zapi.isinstance(obj, ZCMLFile)}
+                    'isclass': isinstance(obj, Class),
+                    'isfunction': isinstance(obj, Function),
+                    'istextfile': isinstance(obj, TextFile),
+                    'iszcmlfile': isinstance(obj, ZCMLFile)}
                    for name, obj in self.context.items()]
         entries.sort(lambda x, y: cmp(x['name'], y['name']))
         if columns:
@@ -89,14 +91,14 @@
         # I really need the class here, so remove the proxy.
         while removeSecurityProxy(module).__class__ is Module:
             crumbs.append(
-                {'name': zapi.name(module),
-                 'url': zapi.absoluteURL(module, self.request)}
+                {'name': getName(module),
+                 'url': absoluteURL(module, self.request)}
                 )
-            module = zapi.getParent(module)
+            module = getParent(module)
 
         crumbs.append(
             {'name': _('[top]'),
-             'url': zapi.getMultiAdapter(
+             'url': getMultiAdapter(
                       (module, self.request), name='absolute_url')()} )
 
         crumbs.reverse()

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/zcml.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/zcml.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/browser/zcml.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -16,15 +16,14 @@
 $Id$
 """
 __docformat__ = "reStructuredText"
+from zope.component import getUtility
 from zope.configuration.fields import GlobalObject, GlobalInterface, Tokens
-from zope.interface import implements
 from zope.interface.interfaces import IInterface
-from zope.schema import getFieldNamesInOrder, getFieldsInOrder
-from zope.schema.interfaces import IFromUnicode
-from zope.security.proxy import removeSecurityProxy
+from zope.schema import getFieldNamesInOrder
+from zope.security.proxy import isinstance, removeSecurityProxy
+from zope.traversing.api import getParent
+from zope.traversing.browser import absoluteURL
 
-from zope.app import zapi
-from zope.app.tree.interfaces import IUniqueId
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.utilities import getPythonPath, isReferencable
 
@@ -34,7 +33,7 @@
 def findDocModule(obj):
     if IDocumentationModule.providedBy(obj):
         return obj
-    return findDocModule(zapi.getParent(obj))
+    return findDocModule(getParent(obj))
 
 def _compareAttrs(x, y, nameOrder):
     if x['name'] in nameOrder:
@@ -72,7 +71,7 @@
         directive = removeSecurityProxy(self.context)
         subDirective = None
         # Sub-directives are not directly documented, so use parent
-        parent = zapi.getParent(directive)
+        parent = getParent(directive)
         if not (IRootDirective.providedBy(parent) or
                 IRootDirective.providedBy(directive)):
             subDirective = directive
@@ -81,11 +80,11 @@
         # Sometimes ns is `None`, especially in the slug files, where no
         # namespaces are used.
         ns = quoteNS(ns or 'ALL')
-        zcml = zapi.getUtility(IDocumentationModule, 'ZCML')
+        zcml = getUtility(IDocumentationModule, 'ZCML')
         if name not in zcml[ns]:
             ns = 'ALL'
         link = '%s/../ZCML/%s/%s/index.html' %(
-            zapi.absoluteURL(findDocModule(self), self.request), ns, name)
+            absoluteURL(findDocModule(self), self.request), ns, name)
         if subDirective:
             link += '#' + subDirective.name[1]
         return link
@@ -118,15 +117,15 @@
                  for (ns, name), value in context.attrs.items()]
 
         names = context.schema.names(True)
-        rootURL = zapi.absoluteURL(findDocModule(self), self.request)
+        rootURL = absoluteURL(findDocModule(self), self.request)
         for attr in attrs:
             name = (attr['name'] in names) and attr['name'] or attr['name']+'_'
             field = context.schema.get(name)
 
-            if zapi.isinstance(field, (GlobalObject, GlobalInterface)):
+            if isinstance(field, (GlobalObject, GlobalInterface)):
                 attr['url'] = self.objectURL(attr['value'], field, rootURL)
 
-            elif zapi.isinstance(field, Tokens):
+            elif isinstance(field, Tokens):
                 field = field.value_type
                 values = attr['value'].strip().split()
                 if len(values) == 1:
@@ -134,7 +133,7 @@
                     attr['url'] = self.objectURL(values[0], field, rootURL)
                 else:
                     for value in values:
-                        if zapi.isinstance(field,
+                        if isinstance(field,
                                            (GlobalObject, GlobalInterface)):
                             url = self.objectURL(value, field, rootURL)
                         else:

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/codemodule.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/codemodule.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/codemodule.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -21,8 +21,7 @@
 __docformat__ = 'restructuredtext'
 
 import zope.component
-from zope.interface import Interface, implements
-from zope.location.interfaces import ILocation
+from zope.interface import implements
 
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.app.apidoc.interfaces import IDocumentationModule

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/directives.txt
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/directives.txt	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/directives.txt	2006-09-07 09:08:16 UTC (rev 70020)
@@ -18,9 +18,9 @@
 Now we can run the directive. First, let's make sure that no root modules have
 been registered yet:
 
-  >>> from zope.app import zapi
+  >>> from zope.component import getUtilitiesFor
   >>> from zope.app.apidoc.codemodule.interfaces import IAPIDocRootModule
-  >>> list(zapi.getUtilitiesFor(IAPIDocRootModule))
+  >>> list(getUtilitiesFor(IAPIDocRootModule))
   []
 
 Now run the registration code:
@@ -33,7 +33,7 @@
 
 and the root module is available:
 
-  >>> list(zapi.getUtilitiesFor(IAPIDocRootModule))
+  >>> list(getUtilitiesFor(IAPIDocRootModule))
   [(u'zope', 'zope')]
 
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/interfaces.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/interfaces.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/interfaces.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -19,7 +19,6 @@
 import zope.interface
 import zope.schema
 
-from zope.app.container.interfaces import IContainer
 from zope.app.container.interfaces import IReadContainer
 from zope.app.i18n import ZopeMessageFactory as _
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/codemodule/zcml.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/codemodule/zcml.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/codemodule/zcml.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -26,7 +26,6 @@
 from zope.interface import implements, directlyProvides
 
 import zope.app.appsetup.appsetup
-from zope.app import zapi
 
 from interfaces import IDirective, IRootDirective, IZCMLFile
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/component.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/component.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/component.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -18,20 +18,19 @@
 __docformat__ = 'restructuredtext'
 import types
 
+from zope.component import getGlobalSiteManager
 from zope.component.interfaces import IFactory
 from zope.component.registry import (
     AdapterRegistration,
     SubscriptionRegistration,
     HandlerRegistration,
     )
-
 from zope.component.registry import UtilityRegistration
 from zope.interface import Interface
 from zope.interface.interface import InterfaceClass
 import zope.interface.declarations
 from zope.publisher.interfaces import IRequest
 
-from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.app.apidoc.classregistry import classRegistry
 from zope.app.apidoc.utilities import relativizePath, truncateSysPath
@@ -45,7 +44,7 @@
 
 def getRequiredAdapters(iface, withViews=False):
     """Get adapter registrations where the specified interface is required."""
-    gsm = zapi.getGlobalSiteManager()
+    gsm = getGlobalSiteManager()
     for meth in ('registeredAdapters',
                  'registeredSubscriptionAdapters',
                  'registeredHandlers'):
@@ -72,7 +71,7 @@
 
 def getProvidedAdapters(iface, withViews=False):
     """Get adapter registrations where this interface is provided."""
-    gsm = zapi.getGlobalSiteManager()
+    gsm = getGlobalSiteManager()
     for reg in _adapterishRegistrations(gsm):
         # Only get adapters
         # Ignore adapters that have no required interfaces
@@ -119,7 +118,7 @@
 def getFactories(iface):
     """Return the factory registrations, who will return objects providing this
     interface."""
-    gsm = zapi.getGlobalSiteManager()
+    gsm = getGlobalSiteManager()
     for reg in gsm.registeredUtilities():
         if reg.provided is not IFactory:
             continue
@@ -136,7 +135,7 @@
 
 def getUtilities(iface):
     """Return all utility registrations that provide the interface."""
-    gsm = zapi.getGlobalSiteManager()
+    gsm = getGlobalSiteManager()
     for reg in gsm.registeredUtilities():
         if reg.provided.isOrExtends(iface):
             yield reg

Modified: Zope3/branches/3.3/src/zope/app/apidoc/disabled.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/disabled.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/disabled.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -17,12 +17,6 @@
 """
 __docformat__ = 'restructuredtext'
 
-import zope.component
-from zope.interface import implements
-from zope.publisher.browser import applySkin
-from zope.location import locate
-from zope.location.interfaces import ILocation
-
 from zope.app.apidoc.interfaces import IDocumentationModule
 from zope.app.apidoc.utilities import ReadContainerBase
 

Modified: Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/browser.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/browser.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/browser.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -19,18 +19,17 @@
 __docformat__ = 'restructuredtext'
 
 import inspect
-from zope.interface import Interface
 
-from zope.publisher.interfaces import IRequest
 from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
 from zope.publisher.interfaces.http import IHTTPRequest
 from zope.publisher.interfaces.ftp import IFTPRequest
 from zope.publisher.browser import BrowserView
-from zope.security.proxy import removeSecurityProxy
+from zope.security.proxy import isinstance, removeSecurityProxy
 from zope.proxy import removeAllProxies
+from zope.traversing.api import getName, getParent
+from zope.traversing.browser import absoluteURL
 
-from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
 
 from zope.app.apidoc.utilities import getPythonPath, renderText
@@ -40,9 +39,9 @@
 
 
 def findAPIDocumentationRoot(obj, request):
-    if zapi.isinstance(obj, APIDocumentation):
-        return zapi.absoluteURL(obj, request)
-    return findAPIDocumentationRoot(zapi.getParent(obj), request)
+    if isinstance(obj, APIDocumentation):
+        return absoluteURL(obj, request)
+    return findAPIDocumentationRoot(getParent(obj), request)
 
 class InterfaceDetails(BrowserView):
     """View class for an Interface."""
@@ -67,7 +66,7 @@
           >>> details.getId()
           'IFoo'
         """
-        return zapi.name(self.context)
+        return getName(self.context)
 
     def getDoc(self):
         r"""Return the main documentation string of the interface.

Modified: Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/ifacemodule.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/ifacemodule.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/ifacemodule/ifacemodule.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -22,7 +22,6 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.app import zapi
 from zope.interface import implements
 from zope.location import LocationProxy
 from zope.component.interface import queryInterface

Modified: Zope3/branches/3.3/src/zope/app/apidoc/presentation.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/presentation.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/presentation.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -15,11 +15,11 @@
 
 $Id$
 """
-from types import ClassType, FunctionType
+from types import ClassType
+from zope.component import getGlobalSiteManager
 from zope.component.registry import AdapterRegistration
 from zope.interface import Interface
 
-from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.app.apidoc.utilities import getPythonPath, relativizePath
 from zope.app.apidoc.utilities import getPermissionIds
@@ -122,7 +122,7 @@
 
 def getViews(iface, type=IRequest):
     """Get all view registrations for a particular interface."""
-    gsm = zapi.getGlobalSiteManager()
+    gsm = getGlobalSiteManager()
     for reg in gsm.registeredAdapters():
         if (len(reg.required) > 0 and
             reg.required[-1] is not None and

Modified: Zope3/branches/3.3/src/zope/app/apidoc/typemodule/browser.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/typemodule/browser.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/typemodule/browser.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -16,16 +16,17 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
-from zope.app import zapi
 from type import TypeInterface
-from zope.security.proxy import removeSecurityProxy
 
+from zope.security.proxy import isinstance, removeSecurityProxy
+from zope.traversing.api import getName
+
 class Menu(object):
     """Menu View Helper Class"""
 
     def getMenuTitle(self, node):
         """Return the title of the node that is displayed in the menu."""
-        if zapi.isinstance(node.context, TypeInterface):
+        if isinstance(node.context, TypeInterface):
             iface = node.context.interface
         else:
             iface = node.context
@@ -34,4 +35,4 @@
 
     def getMenuLink(self, node):
         """Return the HTML link of the node that is displayed in the menu."""
-        return '../Interface/%s/index.html' %zapi.name(node.context)
+        return '../Interface/%s/index.html' % getName(node.context)

Modified: Zope3/branches/3.3/src/zope/app/apidoc/utilities.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/utilities.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/utilities.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -23,14 +23,14 @@
 import inspect
 from os.path import dirname
 
-import zope.app
+from zope.component import createObject, getMultiAdapter
 from zope.interface import implements, implementedBy
 from zope.publisher.browser import TestRequest
 from zope.security.checker import getCheckerForInstancesOf, Global
 from zope.security.interfaces import INameBasedChecker
-from zope.security.proxy import removeSecurityProxy
+from zope.security.proxy import isinstance, removeSecurityProxy
 
-from zope.app import zapi
+import zope.app
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.app.container.interfaces import IReadContainer
 
@@ -152,7 +152,7 @@
 
 
 def _evalId(id):
-    if zapi.isinstance(id, Global):
+    if isinstance(id, Global):
         id = id.__name__
         if id == 'CheckerPublic':
             id = 'zope.Public'
@@ -324,6 +324,6 @@
 
     text = dedentString(text)
 
-    source = zapi.createObject(format, text)
-    renderer = zapi.getMultiAdapter((source, TestRequest()))
+    source = createObject(format, text)
+    renderer = getMultiAdapter((source, TestRequest()))
     return renderer.render()

Modified: Zope3/branches/3.3/src/zope/app/apidoc/utilitymodule/browser.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/utilitymodule/browser.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/utilitymodule/browser.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -17,10 +17,10 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.security.proxy import removeSecurityProxy
+from zope.security.proxy import isinstance, removeSecurityProxy
 from zope.location import LocationProxy
+from zope.traversing.api import getName, getParent
 
-from zope.app import zapi
 from zope.app.apidoc.ifacemodule.browser import InterfaceDetails
 from zope.app.apidoc.component import getUtilityInfoDictionary
 from zope.app.apidoc.utilities import getPythonPath
@@ -59,8 +59,8 @@
     def getMenuTitle(self, node):
         """Return the title of the node that is displayed in the menu."""
         obj = node.context
-        if zapi.isinstance(obj, UtilityInterface):
-            return zapi.name(obj).split('.')[-1]
+        if isinstance(obj, UtilityInterface):
+            return getName(obj).split('.')[-1]
         if obj.name == NONAME:
             return 'no name'
         return obj.name
@@ -68,9 +68,9 @@
     def getMenuLink(self, node):
         """Return the HTML link of the node that is displayed in the menu."""
         obj = node.context
-        if zapi.isinstance(obj, Utility):
-            iface = zapi.getParent(obj)
-            return './'+zapi.name(iface) + '/' + zapi.name(obj) + '/index.html'
-        if zapi.isinstance(obj, UtilityInterface):
-            return '../Interface/'+zapi.name(obj) + '/index.html'
+        if isinstance(obj, Utility):
+            iface = getParent(obj)
+            return './'+getName(iface) + '/' + getName(obj) + '/index.html'
+        if isinstance(obj, UtilityInterface):
+            return '../Interface/'+getName(obj) + '/index.html'
         return None

Modified: Zope3/branches/3.3/src/zope/app/apidoc/zcmlmodule/browser.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/apidoc/zcmlmodule/browser.py	2006-09-07 08:36:51 UTC (rev 70019)
+++ Zope3/branches/3.3/src/zope/app/apidoc/zcmlmodule/browser.py	2006-09-07 09:08:16 UTC (rev 70020)
@@ -20,10 +20,10 @@
 import keyword
 
 from zope.configuration.xmlconfig import ParserInfo
-from zope.security.proxy import removeSecurityProxy
+from zope.security.proxy import isinstance, removeSecurityProxy
 from zope.location import LocationProxy
+from zope.traversing.api import getName, getParent
 
-from zope.app import zapi
 from zope.app.apidoc.zcmlmodule import Directive, Namespace
 from zope.app.apidoc.ifacemodule.browser import InterfaceDetails
 from zope.app.apidoc.utilities import getPythonPath, isReferencable
@@ -35,19 +35,19 @@
     def getMenuTitle(self, node):
         """Return the title of the node that is displayed in the menu."""
         obj = node.context
-        if zapi.isinstance(obj, Namespace):
+        if isinstance(obj, Namespace):
             name = obj.getShortName()
             if name == 'ALL':
                 return 'All Namespaces'
             return name
-        return zapi.name(obj)
+        return getName(obj)
 
     def getMenuLink(self, node):
         """Return the HTML link of the node that is displayed in the menu."""
         obj = node.context
-        if zapi.isinstance(obj, Directive):
-            ns = zapi.getParent(obj)
-            return './'+zapi.name(ns) + '/' + zapi.name(obj) + '/index.html'
+        if isinstance(obj, Directive):
+            ns = getParent(obj)
+            return './'+getName(ns) + '/' + getName(obj) + '/index.html'
         return None
 
 
@@ -75,7 +75,7 @@
 
     def getNamespaceName(self):
         """Return the name of the namespace."""
-        name = zapi.getParent(self.context).getFullName()
+        name = getParent(self.context).getFullName()
         if name == 'ALL':
             return '<i>all namespaces</i>'
         return name
@@ -86,7 +86,7 @@
         # everything is forbidden by default. We need to remove the security
         # proxies in order to get to the data.
         info = removeSecurityProxy(self.context.info)
-        if zapi.isinstance(info, ParserInfo):
+        if isinstance(info, ParserInfo):
             return {'file': relativizePath(info.file),
                     'line': info.line,
                     'column': info.column,



More information about the Zope3-Checkins mailing list