Remove references to zope.app.zapi package ZTK-1.1
authorborax
Mon, 23 May 2011 00:39:14 +0200
branchZTK-1.1
changeset 71 2512d7fe2cda
parent 70 82d8de021806
child 72 d53c864723ea
Remove references to zope.app.zapi package
ztfy/utils/catalog/__init__.py
ztfy/utils/security.py
ztfy/utils/site.py
ztfy/utils/text.py
ztfy/utils/timezone/__init__.py
--- a/ztfy/utils/catalog/__init__.py	Sun May 22 22:37:32 2011 +0200
+++ b/ztfy/utils/catalog/__init__.py	Mon May 23 00:39:14 2011 +0200
@@ -27,7 +27,7 @@
 # import local interfaces
 
 # import Zope3 packages
-from zope.app import zapi
+from zope.component import queryUtility, getAllUtilitiesRegisteredFor
 
 # import local packages
 from ztfy.utils import request as request_utils
@@ -45,7 +45,7 @@
         request = request_utils.getRequest()
     intids = request_utils.getRequestData('IntIdsUtility::' + name, request)
     if intids is None:
-        intids = zapi.queryUtility(IIntIds, name, context=context)
+        intids = queryUtility(IIntIds, name, context=context)
         if intids is not None:
             request_utils.setRequestData('IntIdsUtility::' + name, intids, request)
     return intids
@@ -81,7 +81,7 @@
 
 def queryCatalog(name='', context=None):
     """Look for a registered catalog"""
-    return zapi.queryUtility(ICatalog, name, context=context)
+    return queryUtility(ICatalog, name, context=context)
 
 
 def indexObject(object, catalog_name='', index_name='', request=None, context=None):
@@ -157,8 +157,8 @@
     """Reindex a whole container properties and contents (including annotations) into site's catalogs"""
     if context is None:
         context = object
-    intids = zapi.queryUtility(IIntIds, context=context)
+    intids = queryUtility(IIntIds, context=context)
     if intids is not None:
-        catalogs = zapi.getAllUtilitiesRegisteredFor(ICatalog, context)
+        catalogs = getAllUtilitiesRegisteredFor(ICatalog, context)
         if catalogs:
             _indexAllObject(object, intids, catalogs)
--- a/ztfy/utils/security.py	Sun May 22 22:37:32 2011 +0200
+++ b/ztfy/utils/security.py	Mon May 23 00:39:14 2011 +0200
@@ -20,12 +20,13 @@
 
 # import Zope3 interfaces
 from zope.app.authentication.interfaces import IPrincipalInfo
+from zope.authentication.interfaces import IAuthentication
 
 # import local interfaces
 
 # import Zope3 packages
 from zc.set import Set
-from zope.app import zapi
+from zope.component import getUtility
 from zope.interface import implements
 from zope.security.proxy import removeSecurityProxy
 
@@ -68,7 +69,7 @@
 
 
 def getPrincipal(uid):
-    principals = zapi.principals()
+    principals = getUtility(IAuthentication)
     try:
         return principals.getPrincipal(uid)
     except:
--- a/ztfy/utils/site.py	Sun May 22 22:37:32 2011 +0200
+++ b/ztfy/utils/site.py	Mon May 23 00:39:14 2011 +0200
@@ -24,7 +24,7 @@
 from interfaces import INewSiteManagerEvent
 
 # import Zope3 packages
-from zope.app import zapi
+from zope.component import getUtility
 from zope.interface import implements
 from zope.location import locate
 
@@ -43,6 +43,6 @@
 def locateAndRegister(contained, parent, key, intids=None):
     locate(contained, parent)
     if intids is None:
-        intids = zapi.getUtility(IIntIds)
+        intids = getUtility(IIntIds)
     intids.register(contained)
     parent[key] = contained
--- a/ztfy/utils/text.py	Sun May 22 22:37:32 2011 +0200
+++ b/ztfy/utils/text.py	Mon May 23 00:39:14 2011 +0200
@@ -22,8 +22,7 @@
 # import local interfaces
 
 # import Zope3 packages
-from zope.app import zapi
-from zope.component import createObject
+from zope.component import createObject, queryMultiAdapter
 
 # import local packages
 from request import getRequest
@@ -54,7 +53,7 @@
     if request is None:
         request = getRequest()
     formatter = createObject(renderer, text)
-    renderer = zapi.queryMultiAdapter((formatter, request), name=u'')
+    renderer = queryMultiAdapter((formatter, request), name=u'')
     return renderer.render()
 
 
--- a/ztfy/utils/timezone/__init__.py	Sun May 22 22:37:32 2011 +0200
+++ b/ztfy/utils/timezone/__init__.py	Mon May 23 00:39:14 2011 +0200
@@ -26,8 +26,7 @@
 from interfaces import IServerTimezone
 
 # import Zope3 packages
-from zope.app import zapi
-from zope.component import adapter
+from zope.component import adapter, queryUtility
 from zope.interface import implementer
 
 # import local packages
@@ -40,7 +39,7 @@
 @implementer(ITZInfo)
 @adapter(IBrowserRequest)
 def tzinfo(request=None):
-    util = zapi.queryUtility(IServerTimezone)
+    util = queryUtility(IServerTimezone)
     if util is not None:
         return pytz.timezone(util.timezone)
     return GMT