[Zope-Checkins]
SVN: Products.Five/branches/philikon-local-components/
Remove lots zope.app.zapi and some zope.app.i18n usage.
Philipp von Weitershausen
philikon at philikon.de
Sat Mar 25 06:23:52 EST 2006
Log message for revision 66159:
Remove lots zope.app.zapi and some zope.app.i18n usage.
Note: some resource code seems not to have been tested because they
were still using getView and not getMultiAdapter
Note 2: formlib was using 'zope' i18n domain but zope.formlib code
uses 'zope.formlib' as i18n domain (whether that's good or not is
a different issue)
Changed:
U Products.Five/branches/philikon-local-components/browser/absoluteurl.py
U Products.Five/branches/philikon-local-components/browser/adding.py
U Products.Five/branches/philikon-local-components/browser/metaconfigure.py
U Products.Five/branches/philikon-local-components/browser/resource.py
U Products.Five/branches/philikon-local-components/browser/tests/pages.txt
U Products.Five/branches/philikon-local-components/fiveconfigure.py
U Products.Five/branches/philikon-local-components/form/__init__.py
U Products.Five/branches/philikon-local-components/form/metaconfigure.py
U Products.Five/branches/philikon-local-components/form/tests/test_forms.py
U Products.Five/branches/philikon-local-components/formlib/formbase.py
U Products.Five/branches/philikon-local-components/i18n.py
U Products.Five/branches/philikon-local-components/security.py
U Products.Five/branches/philikon-local-components/skin/standardmacros.py
U Products.Five/branches/philikon-local-components/viewable.py
-=-
Modified: Products.Five/branches/philikon-local-components/browser/absoluteurl.py
===================================================================
--- Products.Five/branches/philikon-local-components/browser/absoluteurl.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/browser/absoluteurl.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -19,7 +19,7 @@
from OFS.interfaces import ITraversable
from zope.interface import implements
-from zope.app import zapi
+from zope.component import getMultiAdapter
from zope.app.traversing.browser.interfaces import IAbsoluteURL
from Products.Five.browser import BrowserView
@@ -52,7 +52,7 @@
return (
{'name': name, 'url': context.absolute_url()},)
- view = zapi.getMultiAdapter((container, request), IAbsoluteURL)
+ view = getMultiAdapter((container, request), IAbsoluteURL)
base = tuple(view.breadcrumbs())
base += (
{'name': name, 'url': ("%s/%s" % (base[-1]['url'], name))},)
Modified: Products.Five/branches/philikon-local-components/browser/adding.py
===================================================================
--- Products.Five/branches/philikon-local-components/browser/adding.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/browser/adding.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -19,30 +19,28 @@
__docformat__ = 'restructuredtext'
from warnings import warn
+
+import zope.component
from zope.interface import implements
from zope.publisher.interfaces import IPublishTraverse
from zope.component.interfaces import IFactory
+from zope.event import notify
from zope.app.exception.interfaces import UserError
from zope.app.container.interfaces import IAdding, INameChooser
from zope.app.container.interfaces import IContainerNamesContainer
from zope.app.container.constraints import checkFactory, checkObject
-
from zope.app.publisher.browser.menu import getMenu
-
-from zope.app import zapi
from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.event import notify
+from Acquisition import Implicit
from zExceptions import BadRequest
+from OFS.SimpleItem import SimpleItem
from Products.Five import BrowserView
from Products.Five.traversable import Traversable
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
-from Acquisition import Implicit
-from OFS.SimpleItem import SimpleItem
-
class BasicAdding(Implicit, BrowserView):
implements(IAdding, IPublishTraverse)
@@ -86,8 +84,8 @@
# XXX this is definitely not right for all or even most uses
# of Five, but can be overridden by an AddView subclass, using
# the class attribute of a zcml:addform directive
- return str(zapi.getMultiAdapter((self.context, self.request),
- name=u"absolute_url")) + '/manage_main'
+ return str(zope.component.getMultiAdapter(
+ (self.context, self.request), name=u"absolute_url")) + '/manage_main'
# set in BrowserView.__init__
request = None
@@ -106,18 +104,18 @@
if view_name.startswith('@@'):
view_name = view_name[2:]
- return zapi.getMultiAdapter((self, request), name=view_name)
+ return zope.component.getMultiAdapter((self, request), name=view_name)
if name.startswith('@@'):
view_name = name[2:]
else:
view_name = name
- view = zapi.queryView(self, view_name, request)
+ view = zope.component.queryMultiAdapter((self, request), name=view_name)
if view is not None:
return view
- factory = zapi.queryUtility(IFactory, name)
+ factory = zope.component.queryUtility(IFactory, name)
if factory is None:
return super(BasicAdding, self).publishTraverse(request, name)
@@ -135,9 +133,10 @@
else:
view_name = type_name
- if zapi.queryView(self, view_name, self.request) is not None:
+ if (zope.component.queryMultiAdapter((self, self.request), name=view_name)
+ is not None):
url = "%s/%s=%s" % (
- zapi.getMultiAdapter((self, self.request), name=u"absolute_url"),
+ zope.component.getMultiAdapter((self, self.request), name=u"absolute_url"),
type_name, id)
self.request.response.redirect(url)
return
@@ -145,7 +144,7 @@
if not self.contentName:
self.contentName = id
- factory = zapi.getUtility(IFactory, type_name)
+ factory = zope.component.getUtility(IFactory, type_name)
content = factory()
notify(ObjectCreatedEvent(content))
@@ -180,7 +179,7 @@
if extra:
factory = extra.get('factory')
if factory:
- factory = zapi.getUtility(IFactory, factory)
+ factory = zope.component.getUtility(IFactory, factory)
if not checkFactory(container, None, factory):
continue
elif item['extra']['factory'] != item['action']:
Modified: Products.Five/branches/philikon-local-components/browser/metaconfigure.py
===================================================================
--- Products.Five/branches/philikon-local-components/browser/metaconfigure.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/browser/metaconfigure.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -20,6 +20,7 @@
"""
import os
+import zope.component
from zope.interface import Interface
from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.browser import IBrowserRequest, \
@@ -192,7 +193,7 @@
if name in pages:
return getattr(self, pages[name])
- view = zapi.queryView(self, name, request)
+ view = zope.component.queryView(self, name, request)
if view is not None:
return view
@@ -205,7 +206,7 @@
if name in pages:
return getattr(self, pages[name])
- view = zapi.queryView(self, name, request)
+ view = zope.component.queryView(self, name, request)
if view is not None:
return view
Modified: Products.Five/branches/philikon-local-components/browser/resource.py
===================================================================
--- Products.Five/branches/philikon-local-components/browser/resource.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/browser/resource.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -23,10 +23,10 @@
from OFS.Traversable import Traversable as OFSTraversable
from zope.interface import implements
+from zope.component import getMultiAdapter
from zope.component.interfaces import IResource
from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.app import zapi
from zope.app.traversing.browser.interfaces import IAbsoluteURL
from zope.app.datetimeutils import time as timeFromDateTimeString
from zope.app.publisher.fileresource import File, Image
@@ -51,7 +51,7 @@
# TODO Zope 3 uses site = getSite() instead of container here
# and the @@ resource access view
- url = str(zapi.getMultiAdapter((container, self.request), IAbsoluteURL))
+ url = str(getMultiAdapter((container, self.request), IAbsoluteURL))
url = urllib.unquote(url)
if not isinstance(container, DirectoryResource):
name = '++resource++%s' % name
Modified: Products.Five/branches/philikon-local-components/browser/tests/pages.txt
===================================================================
--- Products.Five/branches/philikon-local-components/browser/tests/pages.txt 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/browser/tests/pages.txt 2006-03-25 11:23:51 UTC (rev 66159)
@@ -194,12 +194,12 @@
This tests security on a low level (functional pages test has
high-level security tests). Let's manually look up a protected view:
+ >>> from zope.component import getMultiAdapter
+ >>> from zope.app.publication.browser import setDefaultSkin
>>> from Products.Five.traversable import FakeRequest
- >>> from zope.app import zapi
- >>> from zope.app.publication.browser import setDefaultSkin
>>> request = FakeRequest()
>>> setDefaultSkin(request)
- >>> view = zapi.getMultiAdapter((self.folder.testoid, request), name=u'eagle.txt')
+ >>> view = getMultiAdapter((self.folder.testoid, request), name=u'eagle.txt')
It's protecting the object with the permission, and not the attribute,
so we get ('',) instead of ('eagle',):
Modified: Products.Five/branches/philikon-local-components/fiveconfigure.py
===================================================================
--- Products.Five/branches/philikon-local-components/fiveconfigure.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/fiveconfigure.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -28,11 +28,11 @@
from zope.interface import classImplements, classImplementsOnly, implementedBy
from zope.interface.interface import InterfaceClass
+from zope.component import getUtility
from zope.configuration import xmlconfig
from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-from zope.app import zapi
from zope.app.component.interface import provideInterface
from zope.app.component.metaconfigure import adapter
from zope.app.security.interfaces import IPermission
@@ -227,7 +227,7 @@
def _registerClass(class_, meta_type, permission, addview, icon, global_):
setattr(class_, 'meta_type', meta_type)
- permission_obj = zapi.getUtility(IPermission, permission)
+ permission_obj = getUtility(IPermission, permission)
if icon:
setattr(class_, 'icon', '++resource++%s' % icon)
Modified: Products.Five/branches/philikon-local-components/form/__init__.py
===================================================================
--- Products.Five/branches/philikon-local-components/form/__init__.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/form/__init__.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -22,6 +22,8 @@
import transaction
from zope.event import notify
from zope.schema.interfaces import ValidationError
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
from zope.app.location.interfaces import ILocation
from zope.app.location import LocationProxy
@@ -31,7 +33,6 @@
from zope.app.form.utility import setUpWidgets, getWidgetsData
from zope.app.form.interfaces import IInputWidget, WidgetsError
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
-from zope.app.i18n import ZopeMessageFactory as _
from Products.Five.browser import BrowserView
from Products.Five.browser.decode import processInputs, setPageEncoding
Modified: Products.Five/branches/philikon-local-components/form/metaconfigure.py
===================================================================
--- Products.Five/branches/philikon-local-components/form/metaconfigure.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/form/metaconfigure.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -18,14 +18,15 @@
import ExtensionClass
from Globals import InitializeClass as initializeClass
+import zope.component
from zope.interface import Interface
from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
-from zope.app import zapi
from zope.app.publisher.browser.menumeta import menuItemDirective
from zope.app.form.browser.metaconfigure import BaseFormDirective
from zope.app.container.interfaces import IAdding
-from zope.app.i18n import ZopeMessageFactory as _
from Products.Five.form import EditView, AddView
from Products.Five.metaclass import makeClass
@@ -53,7 +54,7 @@
if layer is None:
layer = IDefaultBrowserLayer
- s = zapi.getGlobalSiteManager()
+ s = zope.component.getGlobalSiteManager()
s.provideAdapter((for_, layer), Interface, name, class_)
# Reminder: the permission we got has already been processed by
@@ -116,7 +117,7 @@
if layer is None:
layer = IDefaultBrowserLayer
- s = zapi.getGlobalSiteManager()
+ s = zope.component.getGlobalSiteManager()
s.provideAdapter((for_, layer), Interface, name, class_)
# Reminder: the permission we got has already been processed by
Modified: Products.Five/branches/philikon-local-components/form/tests/test_forms.py
===================================================================
--- Products.Five/branches/philikon-local-components/form/tests/test_forms.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/form/tests/test_forms.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -41,16 +41,16 @@
>>> salutation = salutation.bind(request)
>>> contactname = contactname.bind(request)
- >>> from zope.app import zapi
+ >>> from zope.component import getMultiAdapter
>>> from zope.app.form.interfaces import IInputWidget
>>> from zope.app.form.browser.textwidgets import TextWidget
>>> from zope.app.form.browser.itemswidgets import DropdownWidget
- >>> view1 = zapi.getMultiAdapter((contactname, request), IInputWidget)
+ >>> view1 = getMultiAdapter((contactname, request), IInputWidget)
>>> view1.__class__ == TextWidget
True
- >>> view2 = zapi.getMultiAdapter((salutation, request), IInputWidget)
+ >>> view2 = getMultiAdapter((salutation, request), IInputWidget)
>>> view2.__class__ == DropdownWidget
True
Modified: Products.Five/branches/philikon-local-components/formlib/formbase.py
===================================================================
--- Products.Five/branches/philikon-local-components/formlib/formbase.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/formlib/formbase.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -22,7 +22,7 @@
import zope.app.event.objectevent
from zope import interface
from zope.formlib import interfaces, form, namedtemplate
-from zope.app.i18n import ZopeMessageFactory as _
+from zope.formlib.i18n import _
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
from Products.Five.browser.decode import processInputs, setPageEncoding
Modified: Products.Five/branches/philikon-local-components/i18n.py
===================================================================
--- Products.Five/branches/philikon-local-components/i18n.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/i18n.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -19,7 +19,7 @@
from zope.interface import implements
from zope.i18n import interpolate
from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages
-from zope.app import zapi
+from zope.component import queryUtility
from zope.publisher.browser import BrowserLanguages
# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
@@ -40,7 +40,7 @@
default = msgid.default
mapping = msgid.mapping
- util = zapi.queryUtility(ITranslationDomain, domain)
+ util = queryUtility(ITranslationDomain, domain)
if util is None:
# fallback to translation service that was registered,
Modified: Products.Five/branches/philikon-local-components/security.py
===================================================================
--- Products.Five/branches/philikon-local-components/security.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/security.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -21,7 +21,6 @@
from zope.security.interfaces import IInteraction, ISecurityPolicy
from zope.security.simplepolicies import ParanoidSecurityPolicy
from zope.app.security.interfaces import IPermission
-from zope.app import zapi
from AccessControl import ClassSecurityInfo, getSecurityManager
from Globals import InitializeClass as initializeClass
@@ -67,7 +66,7 @@
return True
if isinstance(permission, StringTypes):
- permission = zapi.queryUtility(IPermission, unicode(permission))
+ permission = queryUtility(IPermission, unicode(permission))
if permission is None:
return False
Modified: Products.Five/branches/philikon-local-components/skin/standardmacros.py
===================================================================
--- Products.Five/branches/philikon-local-components/skin/standardmacros.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/skin/standardmacros.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -16,8 +16,7 @@
$Id$
"""
import zope.interface
-
-from zope.app import zapi
+import zope.component
from Products.Five.browser import BrowserView
# this is a verbatim copy of zope.app.basicskin except that it doesn't
@@ -37,7 +36,7 @@
context = self.context
request = self.request
for name in self.macro_pages:
- page = zapi.getMultiAdapter((context, request), name=name)
+ page = zope.component.getMultiAdapter((context, request), name=name)
try:
v = page[key]
except KeyError:
Modified: Products.Five/branches/philikon-local-components/viewable.py
===================================================================
--- Products.Five/branches/philikon-local-components/viewable.py 2006-03-25 11:04:50 UTC (rev 66158)
+++ Products.Five/branches/philikon-local-components/viewable.py 2006-03-25 11:23:51 UTC (rev 66159)
@@ -20,7 +20,7 @@
from zope.component import ComponentLookupError
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.zapi import getDefaultViewName
+from zope.app.publisher.browser import getDefaultViewName
from Products.Five import fivemethod
from Products.Five.traversable import FakeRequest
More information about the Zope-Checkins
mailing list