[Checkins] SVN: zope.app.dav/trunk/src/zope/app/dav/ Substitute zope.app.zapi by direct calls to its wrapped apis. See bug 219302

Lorenzo Gil lgs at sicem.biz
Mon Apr 21 13:53:57 EDT 2008


Log message for revision 85556:
  Substitute zope.app.zapi by direct calls to its wrapped apis. See bug 219302

Changed:
  U   zope.app.dav/trunk/src/zope/app/dav/propfind.py
  U   zope.app.dav/trunk/src/zope/app/dav/proppatch.py
  U   zope.app.dav/trunk/src/zope/app/dav/tests/test_directives.py

-=-
Modified: zope.app.dav/trunk/src/zope/app/dav/propfind.py
===================================================================
--- zope.app.dav/trunk/src/zope/app/dav/propfind.py	2008-04-21 17:44:42 UTC (rev 85555)
+++ zope.app.dav/trunk/src/zope/app/dav/propfind.py	2008-04-21 17:53:56 UTC (rev 85556)
@@ -17,10 +17,12 @@
 
 from xml.dom import minidom
 from xml.parsers import expat
+from zope.component import getUtilitiesFor, queryMultiAdapter, queryUtility
 from zope.schema import getFieldNamesInOrder, getFields
-from zope.app import zapi
 from zope.app.container.interfaces import IReadContainer
 from zope.app.form.utility import setUpWidgets
+from zope.security import proxy
+from zope.traversing.browser.absoluteurl import absoluteURL
 
 from interfaces import IDAVWidget, IDAVNamespace
 from opaquenamespaces import IDAVOpaqueNamespaces
@@ -45,7 +47,7 @@
 
         _avail_props = {}
         # List all *registered* DAV interface namespaces and their properties
-        for ns, iface in zapi.getUtilitiesFor(IDAVNamespace):
+        for ns, iface in getUtilitiesFor(IDAVNamespace):
             _avail_props[ns] = getFieldNamesInOrder(iface)
         # List all opaque DAV namespaces and the properties we know of
         if self.oprops:
@@ -70,7 +72,7 @@
             self.request.response.setStatus(400)
             return ''
 
-        resource_url = zapi.absoluteURL(self.context, self.request)
+        resource_url = absoluteURL(self.context, self.request)
         if IReadContainer.providedBy(self.context):
             resource_url += '/'
 
@@ -81,7 +83,7 @@
                 pass
 
         self.xmldoc = xmldoc
-            
+
         resp = minidom.Document()
         ms = resp.createElement('multistatus')
         ms.setAttribute('xmlns', self.default_ns)
@@ -115,7 +117,7 @@
             return
         subdepth = (depth == '1') and '0' or 'infinity'
         for id, obj in self.context.items():
-            pfind = zapi.queryMultiAdapter((obj, self.request), name='PROPFIND')
+            pfind = queryMultiAdapter((obj, self.request), name='PROPFIND')
             if pfind is None:
                 continue
             pfind.setDepth(subdepth)
@@ -133,7 +135,7 @@
                   if e.nodeType == e.ELEMENT_NODE]
         for node in childs:
             ns = node.namespaceURI
-            iface = zapi.queryUtility(IDAVNamespace, ns)
+            iface = queryUtility(IDAVNamespace, ns)
             value = props.get(ns, {'iface': iface, 'props': []})
             value['props'].append(node.localName)
             props[ns] = value
@@ -142,7 +144,7 @@
     def _handleAllprop(self):
         props = {}
         for ns, properties in self.avail_props.items():
-            iface = zapi.queryUtility(IDAVNamespace, ns)
+            iface = queryUtility(IDAVNamespace, ns)
             props[ns] = {'iface': iface, 'props': properties}
         return props
 
@@ -262,7 +264,7 @@
                     # Get the widget value here
                     el.appendChild(resp.createTextNode(value))
                 else:
-                    if zapi.isinstance(value, minidom.Node):
+                    if proxy.isinstance(value, minidom.Node):
                         el.appendChild(
                             el.ownerDocument.importNode(value, True))
                     else:

Modified: zope.app.dav/trunk/src/zope/app/dav/proppatch.py
===================================================================
--- zope.app.dav/trunk/src/zope/app/dav/proppatch.py	2008-04-21 17:44:42 UTC (rev 85555)
+++ zope.app.dav/trunk/src/zope/app/dav/proppatch.py	2008-04-21 17:53:56 UTC (rev 85556)
@@ -18,11 +18,12 @@
 from xml.dom import minidom
 
 import transaction
-from zope.app import zapi
+from zope.component import getUtilitiesFor, queryUtility
 from zope.schema import getFieldNamesInOrder, getFields
 from zope.app.container.interfaces import IReadContainer
 from zope.publisher.http import status_reasons
 from zope.app.form.utility import setUpWidget, no_value
+from zope.traversing.browser.absoluteurl import absoluteURL
 
 from interfaces import IDAVNamespace, IDAVWidget
 from opaquenamespaces import IDAVOpaqueNamespaces
@@ -46,7 +47,7 @@
 
         _avail_props = {}
         # List all *registered* DAV interface namespaces and their properties
-        for ns, iface in zapi.getUtilitiesFor(IDAVNamespace):
+        for ns, iface in getUtilitiesFor(IDAVNamespace):
             _avail_props[ns] = getFieldNamesInOrder(iface)
         # List all opaque DAV namespaces and the properties we know of
         if self.oprops:
@@ -59,7 +60,7 @@
             self.request.response.setStatus(400)
             return ''
 
-        resource_url = zapi.absoluteURL(self.context, self.request)
+        resource_url = absoluteURL(self.context, self.request)
         if IReadContainer.providedBy(self.context):
             resource_url += '/'
 
@@ -143,7 +144,7 @@
 
     def _handleSet(self, prop):
         ns = prop.namespaceURI
-        iface = zapi.queryUtility(IDAVNamespace, ns)
+        iface = queryUtility(IDAVNamespace, ns)
         if not iface:
             # opaque DAV properties
             if self.oprops is not None:
@@ -185,7 +186,7 @@
         ns = prop.namespaceURI
         if not prop.localName in self.avail_props.get(ns, []):
             return 200
-        iface = zapi.queryUtility(IDAVNamespace, ns)
+        iface = queryUtility(IDAVNamespace, ns)
         if not iface:
             # opaque DAV properties
             if self.oprops is None:

Modified: zope.app.dav/trunk/src/zope/app/dav/tests/test_directives.py
===================================================================
--- zope.app.dav/trunk/src/zope/app/dav/tests/test_directives.py	2008-04-21 17:44:42 UTC (rev 85555)
+++ zope.app.dav/trunk/src/zope/app/dav/tests/test_directives.py	2008-04-21 17:53:56 UTC (rev 85556)
@@ -20,7 +20,7 @@
 from zope.configuration import xmlconfig
 from zope.interface import Interface
 
-from zope.app import zapi
+from zope.component import getGlobalSiteManager
 from zope.app.testing.placelesssetup import PlacelessSetup
 from zope.app.dav.interfaces import IDAVNamespace
 import zope.app.dav.tests
@@ -33,7 +33,7 @@
 class DirectivesTest(PlacelessSetup, unittest.TestCase):
 
     def test_provideInterface(self):
-        sm = zapi.getGlobalSiteManager()
+        sm = getGlobalSiteManager()
         self.assertEqual(sm.queryUtility(IDAVNamespace, ns), None)
         self.context = xmlconfig.file("dav.zcml", zope.app.dav.tests)
         self.assertEqual(sm.queryUtility(IDAVNamespace, ns), ISchema)



More information about the Checkins mailing list