[Zope3-checkins] SVN: Zope3/trunk/src/zope/ - Created functions to
encapsulate the thread-global management of
Jim Fulton
jim at zope.com
Sat May 22 14:31:48 EDT 2004
Log message for revision 24884:
- Created functions to encapsulate the thread-global management of
sites because we don't actually want to store the site in the thread
global. We want to store the site manager. Later, there is some
interesting caching that we can do. We need to encapsulate the site
management to do this.
- Caused PlacefulSetup to register the site when someone calls
makeSite.
- Added an API function, getGlobalService to explicitly get a global
service.
-=-
Modified: Zope3/trunk/src/zope/app/adapter/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/adapter/adapter.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/adapter/adapter.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -256,7 +256,7 @@
def __init__(self, base=None):
if base is None:
- base = zapi.getService(None, self.serviceType)
+ base = zapi.getGlobalService(self.serviceType)
LocalAdapterRegistry.__init__(self, base)
def registrations(self, localOnly=False):
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -102,7 +102,7 @@
ztapi.provideUtility(IFactory, Factory(Foo, title='Foo Factory'),
'FooFactory')
ztapi.provideUtility(IFoo, Foo(), 'The Foo')
- sm = zapi.getService(None, 'Services')
+ sm = zapi.getGlobalServices()
sm.defineService('Foo', IFoo)
sm.provideService('Foo', Foo())
Modified: Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -78,7 +78,7 @@
queried using::
>>> from zope.app import zapi
- >>> service = zapi.getService(None, 'ServiceName')
+ >>> service = zapi.getGlobalService('ServiceName')
Here we used 'None' as the location, which means that always a global
service is returned. If you use an object that has a location in the
Modified: Zope3/trunk/src/zope/app/apidoc/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/apidoc/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -30,8 +30,9 @@
def setUp():
placelesssetup.setUp()
- service = zapi.getService(None, 'Utilities')
- service.provideUtility(IDocumentationModule, InterfaceModule(), 'Interface')
+ service = zapi.getGlobalService('Utilities')
+ service.provideUtility(IDocumentationModule, InterfaceModule(),
+ 'Interface')
service.provideUtility(IDocumentationModule, ZCMLModule(), 'ZCML')
def tearDown():
Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -40,7 +40,7 @@
def setUp():
placelesssetup.setUp()
- service = zapi.getService(None, 'Utilities')
+ service = zapi.getGlobalService('Utilities')
service.provideUtility(IDocumentationModule, InterfaceModule(), '')
service.provideUtility(IDocumentationModule, ClassModule(), 'Classes')
Modified: Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -99,7 +99,7 @@
>>> skins
['skinA', 'skinB', 'skinC']
- >>> pres = zapi.getService(None, 'Presentation')
+ >>> pres = zapi.getGlobalService('Presentation')
>>> pres.defineSkin('skinD', ['layer3'])
>>> skins = [skin.name for skin in module.getSkins()]
>>> skins.sort()
@@ -107,7 +107,7 @@
['skinA', 'skinB', 'skinC', 'skinD']
"""
# Only the global presentation service defines skins
- service = zapi.getService(None, 'Presentation')
+ service = zapi.getGlobalService('Presentation')
skins = [zapi.getAdapter(reg, ISkinDocumentation)
for reg in service.registrations()
if isinstance(reg, SkinRegistration)]
@@ -126,7 +126,7 @@
>>> from zope.app.apidoc.tests import pprint
- >>> pres = zapi.getService(None, 'Presentation')
+ >>> pres = zapi.getGlobalService('Presentation')
>>> reg = pres._registrations[('skin', 'skinA')]
>>> doc = SkinDocumentation(reg)
>>> doc.name
Modified: Zope3/trunk/src/zope/app/apidoc/viewmodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/viewmodule/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/apidoc/viewmodule/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -42,7 +42,7 @@
ztapi.provideAdapter(ILayerRegistration, ILayerDocumentation,
LayerDocumentation)
- pres = zapi.getService(None, 'Presentation')
+ pres = zapi.getGlobalService('Presentation')
for index in range(1, 6):
pres.defineLayer('layer'+str(index))
pres.defineSkin('skinA', ['default'], 'doc skin A')
Modified: Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -48,7 +48,8 @@
def test_ServerControlView(self):
control = ServerControlStub()
- zapi.getService(None, Utilities).provideUtility(IServerControl, control)
+ zapi.getGlobalService(Utilities).provideUtility(
+ IServerControl, control)
test_serverctrl = self._TestView__newView(
applicationController,
Modified: Zope3/trunk/src/zope/app/cache/tests/test_cachename.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/tests/test_cachename.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/cache/tests/test_cachename.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -25,8 +25,8 @@
from zope.app.site.tests.placefulsetup import PlacefulSetup
from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.utility import LocalUtilityService
-from zope.thread import thread_globals
+
class CacheStub(object):
__name__ = __parent__ = None
implements(ICache, IAttributeAnnotatable)
@@ -39,17 +39,12 @@
def setUp(self):
PlacefulSetup.setUp(self, folders=True)
sm = self.makeSite()
- thread_globals().site = sm.__parent__
setup.addService(sm, 'Utilities', LocalUtilityService())
setup.addUtility(sm, 'bar', ICache, CacheStub())
setup.addUtility(sm, 'baz', ICache, CacheStub())
setup.addUtility(sm, 'foo', ICache, CacheStub())
- def tearDown(self):
- PlacefulSetup.tearDown(self)
- thread_globals().site = None
-
def test(self):
field = CacheName().bind(self.rootFolder)
allowed = list(field.allowed_values)
Modified: Zope3/trunk/src/zope/app/component/contentdirective.py
===================================================================
--- Zope3/trunk/src/zope/app/component/contentdirective.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/component/contentdirective.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -39,7 +39,7 @@
pass
def handler(serviceName, methodName, *args, **kwargs):
- method=getattr(zapi.getService(None, serviceName), methodName)
+ method=getattr(zapi.getGlobalService(serviceName), methodName)
method(*args, **kwargs)
class ContentDirective:
Modified: Zope3/trunk/src/zope/app/component/hooks.py
===================================================================
--- Zope3/trunk/src/zope/app/component/hooks.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/component/hooks.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -31,14 +31,33 @@
from zope.interface import Interface
from zope.thread import thread_globals
+def setSite(site=None):
+ if site is None:
+ services = None
+ else:
+ services = trustedRemoveSecurityProxy(site.getSiteManager())
+
+ thread_globals().services = services
+
+def getSite():
+ services = thread_globals().services
+ if services is None:
+ return None
+ return services.__parent__
+
+
def getServices_hook(context=None):
if context is None:
- site = thread_globals().site
- if site is None:
+ try:
+ services = thread_globals().services
+ except AttributeError:
+ thread_globals().services = services = None
+
+ if services is None:
return serviceManager
else:
- return trustedRemoveSecurityProxy(site.getSiteManager())
+ return services
try:
# This try-except is just backward compatibility really
Modified: Zope3/trunk/src/zope/app/component/interface.py
===================================================================
--- Zope3/trunk/src/zope/app/component/interface.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/component/interface.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -28,7 +28,7 @@
>>> from zope.app.tests.placelesssetup import setUp, tearDown
>>> setUp()
- >>> utilities = zapi.getService(None, zapi.servicenames.Utilities)
+ >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
>>> from zope.interface import Interface
>>> from zope.interface.interfaces import IInterface
>>> from zope.app.content.interfaces import IContentType
@@ -79,7 +79,7 @@
else:
iface_type = IInterface
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(iface_type, interface, name=id)
@@ -89,7 +89,7 @@
>>> from zope.app.tests.placelesssetup import setUp, tearDown
>>> setUp()
- >>> utilities = zapi.getService(None, zapi.servicenames.Utilities)
+ >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
>>> from zope.interface import Interface
>>> from zope.app.content.interfaces import IContentType
>>> class I4(Interface):
@@ -123,7 +123,7 @@
>>> from zope.app.tests.placelesssetup import setUp, tearDown
>>> tearDown()
>>> setUp()
- >>> utilities = zapi.getService(None, zapi.servicenames.Utilities)
+ >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
>>> from zope.interface import Interface
>>> from zope.interface.interfaces import IInterface
>>> from zope.app.content.interfaces import IContentType
@@ -152,7 +152,7 @@
>>> from zope.app.tests.placelesssetup import setUp, tearDown
>>> setUp()
- >>> utilities = zapi.getService(None, zapi.servicenames.Utilities)
+ >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
>>> from zope.interface import Interface
>>> from zope.interface.interfaces import IInterface
>>> from zope.app.content.interfaces import IContentType
@@ -185,7 +185,7 @@
>>> from zope.app.tests.placelesssetup import setUp, tearDown
>>> setUp()
- >>> utilities = zapi.getService(None, zapi.servicenames.Utilities)
+ >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
>>> from zope.interface import Interface
>>> from zope.interface.interfaces import IInterface
>>> from zope.app.content.interfaces import IContentType
@@ -214,7 +214,7 @@
def searchInterfaceUtilities(context, search_string=None, base=None):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
iface_utilities = utilityService.getUtilitiesFor(IInterface)
if search_string:
Modified: Zope3/trunk/src/zope/app/component/localservice.py
===================================================================
--- Zope3/trunk/src/zope/app/component/localservice.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/component/localservice.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -23,8 +23,8 @@
from zope.proxy import removeAllProxies
from zope.app.site.interfaces import ISite, ISiteManager
from zope.app.event.interfaces import ISubscriber
-from zope.thread import thread_globals
from zope.testing.cleanup import addCleanUp
+from zope.app.component.hooks import setSite
# placeful service manager convenience tools
@@ -139,7 +139,7 @@
implements(ISubscriber)
def notify(self, event):
if ISite.providedBy(event.object):
- thread_globals().site = event.object
+ setSite(event.object)
threadSiteSubscriber = ThreadSiteSubscriber()
@@ -158,8 +158,7 @@
clearThreadSiteSubscriber = ClearThreadSiteSubscriber()
-def clearSite():
- """Clear the site thread global"""
- thread_globals().site = None
+# Clear the site thread global
+clearSite = setSite
addCleanUp(clearSite)
Modified: Zope3/trunk/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metaconfigure.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/component/metaconfigure.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -41,7 +41,7 @@
def handler(serviceName, methodName, *args, **kwargs):
- method=getattr(zapi.getService(None, serviceName), methodName)
+ method=getattr(zapi.getGlobalService(serviceName), methodName)
method(*args, **kwargs)
# We can't use the handler for serviceType, because serviceType needs
Modified: Zope3/trunk/src/zope/app/component/tests/test_localservice.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_localservice.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/component/tests/test_localservice.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -24,13 +24,12 @@
from zope.component.exceptions import ComponentLookupError
from zope.component.interfaces import IServiceService
from zope.component.service import serviceManager
-from zope.thread import thread_globals
from zope.interface import implements, directlyProvides, directlyProvidedBy
from zope.interface.verify import verifyObject
from zope.app.event.interfaces import ISubscriber
-from zope.thread import thread_globals
from zope.app.tests.setup import placelessSetUp, placelessTearDown
from zope.app.tests import ztapi
+from zope.app.component.hooks import setSite, getSite
class ServiceManager:
implements(ISiteManager)
@@ -106,7 +105,7 @@
ztapi.provideAdapter(None, IServiceService, serviceServiceAdapter)
def tearDown(self):
- thread_globals().site = None
+ setSite()
placelessTearDown()
def test_getServices(self):
@@ -114,7 +113,7 @@
self.assertEqual(getServices_hook(self.root), serviceManager)
self.assertEqual(getServices_hook(self.f1), self.sm1)
self.assertEqual(getServices_hook(self.f2), self.sm2)
- thread_globals().site = self.f2
+ setSite(self.f2)
self.assertEqual(getServices_hook(None), self.sm2)
def test_queryNextService(self):
@@ -235,8 +234,7 @@
verifyObject(ISubscriber, threadSiteSubscriber)
- globals = thread_globals()
- self.assertEqual(globals.site, None)
+ self.assertEqual(getSite(), None)
# A non-site is traversed
ob = object()
@@ -244,7 +242,7 @@
ev = BeforeTraverseEvent(ob, request)
threadSiteSubscriber.notify(ev)
- self.assertEqual(globals.site, None)
+ self.assertEqual(getSite(), None)
# A site is traversed
ss = ServiceServiceStub()
@@ -254,11 +252,11 @@
ev = BeforeTraverseEvent(site, request)
threadSiteSubscriber.notify(ev)
- self.assertEqual(globals.site, site)
+ self.assertEqual(getSite(), site)
clearSite()
- self.assertEqual(globals.site, None)
+ self.assertEqual(getSite(), None)
def test_suite():
Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -192,7 +192,7 @@
def test_constraint_driven_addingInfo():
"""
>>> setUp()
- >>> serviceService = zapi.getService(None, zapi.servicenames.Services)
+ >>> serviceService = zapi.getGlobalServices()
>>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
>>> serviceService.defineService(zapi.servicenames.BrowserMenu,
... IBrowserMenuService)
@@ -201,7 +201,7 @@
>>> serviceService.provideService(zapi.servicenames.BrowserMenu,
... globalBrowserMenuService)
- >>> menuService = zapi.getService(None, zapi.servicenames.BrowserMenu)
+ >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
>>> menuService.menu('test', '')
>>> menuService.menuItem('test', IAdding, '', 'item1', None)
>>> menuService.menuItem('test', IAdding, '', 'item2', None)
@@ -395,7 +395,7 @@
the container contains only a single content object
>>> setUp()
- >>> serviceService = zapi.getService(None, zapi.servicenames.Services)
+ >>> serviceService = zapi.getGlobalServices()
>>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
>>> serviceService.defineService(zapi.servicenames.BrowserMenu,
... IBrowserMenuService)
@@ -404,7 +404,7 @@
>>> serviceService.provideService(zapi.servicenames.BrowserMenu,
... globalBrowserMenuService)
- >>> menuService = zapi.getService(None, zapi.servicenames.BrowserMenu)
+ >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
>>> menuService.menu('zope.app.container.add', '')
>>> menuService.menuItem('zope.app.container.add', IAdding, '', 'item3',
... None, extra={'factory': 'f1'})
@@ -466,7 +466,7 @@
implement IContainerNamesContainer
>>> setUp()
- >>> serviceService = zapi.getService(None, zapi.servicenames.Services)
+ >>> serviceService = zapi.getGlobalServices()
>>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
>>> serviceService.defineService(zapi.servicenames.BrowserMenu,
... IBrowserMenuService)
@@ -475,7 +475,7 @@
>>> serviceService.provideService(zapi.servicenames.BrowserMenu,
... globalBrowserMenuService)
- >>> menuService = zapi.getService(None, zapi.servicenames.BrowserMenu)
+ >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
>>> menuService.menu('zope.app.container.add', '')
>>> menuService.menuItem('zope.app.container.add', None, '', 'item3',
... None, extra={'factory': ''})
@@ -535,7 +535,7 @@
>>> setUp()
- >>> serviceService = zapi.getService(None, zapi.servicenames.Services)
+ >>> serviceService = zapi.getGlobalServices()
>>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
>>> serviceService.defineService(zapi.servicenames.BrowserMenu,
... IBrowserMenuService)
@@ -544,7 +544,7 @@
>>> serviceService.provideService(zapi.servicenames.BrowserMenu,
... globalBrowserMenuService)
- >>> menuService = zapi.getService(None, zapi.servicenames.BrowserMenu)
+ >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
>>> menuService.menu('zope.app.container.add', '')
>>> menuService.menuItem('zope.app.container.add', None, '', 'item3',
... None, extra={'factory': ''})
Modified: Zope3/trunk/src/zope/app/dav/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/test_directives.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/dav/tests/test_directives.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -34,7 +34,7 @@
class DirectivesTest(PlacelessSetup, unittest.TestCase):
def test_provideInterface(self):
- utils = zapi.getService(None, Utilities)
+ utils = zapi.getGlobalService(Utilities)
self.assertEqual(utils.queryUtility(IDAVNamespace, name=ns), None)
self.context = xmlconfig.file("dav.zcml", zope.app.dav.tests)
self.assertEqual(utils.queryUtility(IDAVNamespace, name=ns), ISchema)
Modified: Zope3/trunk/src/zope/app/dav/tests/test_propfind.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/test_propfind.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/dav/tests/test_propfind.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -132,7 +132,7 @@
root['folder'] = folder
self.zpt = traverse(root, 'zpt')
self.file = traverse(root, 'file')
- ps = zapi.getService(None, zapi.servicenames.Presentation)
+ ps = zapi.getGlobalService(zapi.servicenames.Presentation)
ps.provideView(None, 'absolute_url', IHTTPRequest,
AbsoluteURL)
ps.provideView(None, 'PROPFIND', IHTTPRequest,
@@ -144,7 +144,7 @@
ztapi.provideAdapter(IAnnotatable, IAnnotations, AttributeAnnotations)
ztapi.provideAdapter(IAnnotatable, IZopeDublinCore,
ZDCAnnotatableAdapter)
- utils = zapi.getService(None, 'Utilities')
+ utils = zapi.getGlobalService('Utilities')
directlyProvides(IDAVSchema, IDAVNamespace)
utils.provideUtility(IDAVNamespace, IDAVSchema, 'DAV:')
directlyProvides(IZopeDublinCore, IDAVNamespace)
Modified: Zope3/trunk/src/zope/app/form/browser/add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/add.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/add.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -136,7 +136,7 @@
keyword_arguments, set_before_add, set_after_add,
menu=u''):
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
class_ = SimpleViewClass(
template,
used_for = schema, bases = bases
Modified: Zope3/trunk/src/zope/app/form/browser/addwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/addwizard.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/addwizard.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -134,5 +134,5 @@
)
)
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.provideView(for_, name, IBrowserRequest, class_, layer)
Modified: Zope3/trunk/src/zope/app/form/browser/editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editview.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/editview.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -123,7 +123,7 @@
def EditViewFactory(name, schema, label, permission, layer,
template, default_template, bases, for_, fields,
fulledit_path=None, fulledit_label=None, menu=u''):
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
class_ = SimpleViewClass(template, used_for=schema, bases=bases)
class_.schema = schema
class_.label = label
Modified: Zope3/trunk/src/zope/app/form/browser/editwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editwizard.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/editwizard.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -235,7 +235,7 @@
NamesChecker(("__call__", "__getitem__", "browserDefault"), permission)
)
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.provideView(for_, name, IBrowserRequest, class_, layer)
Modified: Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -87,5 +87,5 @@
defineChecker(class_,
NamesChecker(("__call__", "__getitem__", "browserDefault"),
permission))
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.provideView(for_, name, IBrowserRequest, class_, layer)
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -32,7 +32,7 @@
def provideMultiView(for_, factory, providing, name='', layer="default"):
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
return s.provideAdapter(IBrowserRequest, factory, name, for_,
providing, layer)
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -29,7 +29,7 @@
def provideMultiView(for_, factory, providing, name='', layer="default"):
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
return s.provideAdapter(IBrowserRequest, factory, name, for_,
providing, layer)
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -88,7 +88,7 @@
ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
- ps = zapi.getService(None, zapi.servicenames.Presentation)
+ ps = zapi.getGlobalService(zapi.servicenames.Presentation)
def testAddForm(self):
self.assertEqual(zapi.queryView(ob, 'test', request),
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -33,7 +33,7 @@
def provideMultiView(for_, factory, providing, name='', layer="default"):
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
return s.provideAdapter(IBrowserRequest, factory, name, for_,
providing, layer)
Modified: Zope3/trunk/src/zope/app/mail/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/metaconfigure.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/mail/metaconfigure.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -42,7 +42,7 @@
delivery = QueuedMailDelivery(queuePath)
delivery = _assertPermission(permission, IMailDelivery, delivery)
- utilities = zapi.getService(None, 'Utilities')
+ utilities = zapi.getGlobalService('Utilities')
handler('Utilities', 'provideUtility', IMailDelivery, delivery, name)
mailerObject = zapi.queryUtility(IMailer, name=mailer)
@@ -71,7 +71,7 @@
delivery = DirectMailDelivery(mailerObject)
delivery = _assertPermission(permission, IMailDelivery, delivery)
- utilities = zapi.getService(None, 'Utilities')
+ utilities = zapi.getGlobalService('Utilities')
handler('Utilities', 'provideUtility', IMailDelivery, delivery, name)
_context.action(
Modified: Zope3/trunk/src/zope/app/menu/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/__init__.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/menu/browser/__init__.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -80,7 +80,7 @@
for id, menu in utilities.getUtilitiesFor(ILocalBrowserMenu):
menus.append(self._getInfoFromMenu(id, menu))
# Global Browser Menus
- service = zapi.getService(None, BrowserMenu)
+ service = zapi.getGlobalService(BrowserMenu)
for id, menu in service._registry.items():
menus.append(self._getInfoFromMenu(id, menu))
return menus
Modified: Zope3/trunk/src/zope/app/menu/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/menu/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/menu/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -96,8 +96,8 @@
classImplements(LocalBrowserMenu, IAttributeAnnotatable)
# Create Placeless Components
- ps = zapi.getService(None, zapi.servicenames.Presentation)
- ms = zapi.getService(None, BrowserMenu)
+ ps = zapi.getGlobalService(zapi.servicenames.Presentation)
+ ms = zapi.getGlobalService(BrowserMenu)
ms.menu('test_id', 'test menu')
ms.menu('test_id2', 'test menu 2')
ms.menu('test_id3', 'test menu 3')
Modified: Zope3/trunk/src/zope/app/pagetemplate/tests/test_viewzpt.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/tests/test_viewzpt.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/pagetemplate/tests/test_viewzpt.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -66,7 +66,7 @@
from zope.component.interfaces import IPresentationRequest
- zapi.getService(None, zapi.servicenames.Presentation).provideView(
+ zapi.getGlobalService(zapi.servicenames.Presentation).provideView(
I1,
name=the_view_name,
type=IPresentationRequest,
Modified: Zope3/trunk/src/zope/app/presentation/presentation.py
===================================================================
--- Zope3/trunk/src/zope/app/presentation/presentation.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/presentation/presentation.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -59,7 +59,7 @@
def __init__(self):
self.layers = persistent.dict.PersistentDict()
- self.base = zapi.getService(None, zapi.servicenames.Presentation)
+ self.base = zapi.getGlobalService(zapi.servicenames.Presentation)
def setNext(self, next, global_):
if next is None:
Modified: Zope3/trunk/src/zope/app/presentation/tests/test_pagefolder.py
===================================================================
--- Zope3/trunk/src/zope/app/presentation/tests/test_pagefolder.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/presentation/tests/test_pagefolder.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -48,7 +48,7 @@
def setUp(self):
sm = PlacefulSetup.setUp(self, site=True)
- zapi.getService(None, Presentation).defineLayer('debug')
+ zapi.getGlobalService(Presentation).defineLayer('debug')
setup.addService(sm, Presentation, LocalPresentationService(),
suffix='service')
default = zapi.traverse(self.rootFolder, '++etc++site/default')
Modified: Zope3/trunk/src/zope/app/presentation/tests/test_presentation.py
===================================================================
--- Zope3/trunk/src/zope/app/presentation/tests/test_presentation.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/presentation/tests/test_presentation.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -135,14 +135,14 @@
def test_defaultSkin(self):
# XXX we don't let people set the default skin locally yet.
# So just test that we can get the default from the global service
- zapi.getService(None, Presentation).defineSkin('bob', ['default'])
- zapi.getService(None, Presentation).setDefaultSkin('bob')
+ zapi.getGlobalService(Presentation).defineSkin('bob', ['default'])
+ zapi.getGlobalService(Presentation).setDefaultSkin('bob')
self.assertEqual(self._service.defaultSkin, 'bob')
def test_querySkin(self):
# XXX we don't let people define skins locally yet.
# So just test that we can get the defs from the global service
- globalService = zapi.getService(None, Presentation)
+ globalService = zapi.getGlobalService(Presentation)
globalService.defineLayer('bob')
globalService.defineSkin('bob', ['bob', 'default'])
self.assertEqual(self._service.querySkin('bob'), ('bob', 'default'))
@@ -150,7 +150,7 @@
def test_queryLayer(self):
# XXX we don't let people define layers locally yet.
# So just test that we can get the them from the global service
- globalService = zapi.getService(None, Presentation)
+ globalService = zapi.getGlobalService(Presentation)
layer = self._service.queryLayer('default')
self.assertEqual(layer.__parent__, globalService)
self.test_queryView()
@@ -167,7 +167,7 @@
r = TestRequest()
self.assertEqual(self._service.queryDefaultViewName(o, r),
None)
- globalService = zapi.getService(None, Presentation)
+ globalService = zapi.getGlobalService(Presentation)
globalService.setDefaultViewName(I1, IBrowserRequest, 'foo.html')
self.assertEqual(self._service.queryDefaultViewName(o, r),
'foo.html')
@@ -185,7 +185,7 @@
self.assertEqual(self._service.queryMultiView((x, y), r,
name='foo.html'),
None)
- globalService = zapi.getService(None, Presentation)
+ globalService = zapi.getGlobalService(Presentation)
class MV:
def __init__(self, x, y, request):
@@ -212,7 +212,7 @@
def __init__(self, request):
self.request = request
- globalService = zapi.getService(None, Presentation)
+ globalService = zapi.getGlobalService(Presentation)
globalService.provideResource('logo.gif', IBrowserRequest, Resource)
resource = self._service.queryResource('logo.gif', r)
Modified: Zope3/trunk/src/zope/app/publication/tests/test_http.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_http.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/publication/tests/test_http.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -46,7 +46,7 @@
request = HTTPRequest(StringIO(''), StringIO(), {})
request.method = 'SPAM'
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.provideView(I, 'SPAM', IHTTPRequest, V)
ob = C()
Modified: Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -191,11 +191,11 @@
class IConflictError(Interface):
pass
classImplements(ConflictError, IConflictError)
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.setDefaultViewName(IConflictError,
self.presentation_type, 'name')
view_text = 'You had a conflict error'
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.provideView(IConflictError, 'name', self.presentation_type,
lambda obj, request: lambda: view_text)
try:
@@ -215,7 +215,7 @@
class IClassicError(Interface):
pass
classImplements(ClassicError, IClassicError)
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.setDefaultViewName(IClassicError, self.presentation_type, 'name')
view_text = 'You made a classic error ;-)'
s.provideView(IClassicError, 'name', self.presentation_type,
@@ -365,7 +365,7 @@
from zope.app.container.interfaces import ISimpleReadContainer
from zope.app.container.traversal import ContainerTraverser
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
s.provideView(ISimpleReadContainer, '', IRequest,
ContainerTraverser, providing=IPublishTraverse)
Modified: Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -193,7 +193,7 @@
def menu(self, menu_id, title, description=u''):
# XXX we have nothing to do with the title and description. ;)
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
if menu_id in self._registry:
raise DuplicationError("Menu %s is already defined." % menu_id)
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -102,7 +102,7 @@
ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
- ps = zapi.getService(None, zapi.servicenames.Presentation)
+ ps = zapi.getGlobalService(zapi.servicenames.Presentation)
def testPage(self):
self.assertEqual(queryView(ob, 'test', request),
Modified: Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -99,7 +99,7 @@
):
try:
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
except ComponentLookupError, err:
pass
@@ -265,7 +265,7 @@
for pname, attribute, template in self.pages:
try:
- s = zapi.getService(None, zapi.servicenames.Presentation)
+ s = zapi.getGlobalService(zapi.servicenames.Presentation)
except ComponentLookupError, err:
pass
Modified: Zope3/trunk/src/zope/app/pythonpage/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/pythonpage/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/pythonpage/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -38,7 +38,7 @@
def setUp():
placelesssetup.setUp()
- service = zapi.getService(None, Utilities)
+ service = zapi.getGlobalService(Utilities)
service.provideUtility(IInterpreter, PythonInterpreter,
'text/server-python')
Modified: Zope3/trunk/src/zope/app/rdb/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/metaconfigure.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/rdb/metaconfigure.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -31,7 +31,7 @@
Uses the Utility Service for registering
"""
- utilities = zapi.getService(None, zapi.servicenames.Utilities)
+ utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
utilities.provideUtility(IZopeDatabaseAdapter, connection, name)
Modified: Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -96,7 +96,7 @@
utility.LocalUtilityService())
def test_getLocalInterface_delegates_to_globalUtility(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, Bar("blob"),
name="blob")
utilityService.provideUtility(IBaz, Baz("global baz"))
@@ -111,7 +111,7 @@
baz = Baz("global baz")
foo = Foo("global bob")
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, foo,
name="bob")
utilityService.provideUtility(IInterface, bar)
@@ -136,7 +136,7 @@
bar = Bar("global")
baz = Baz("global baz")
foo = Foo("global bob")
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, foo,
name="bob")
utilityService.provideUtility(ILocalUtility, bar)
@@ -155,7 +155,7 @@
self.assertEqual(ifaces, [(baz)])
def test_getLocalInterface_raisesComponentLookupError(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, Foo("global"))
utilityService.provideUtility(IBaz, Baz("global baz"))
utilityService.provideUtility(IInterface, Foo("global bob"),
@@ -168,7 +168,7 @@
foo = Foo("global bob")
bar = Bar("global")
baz = Baz("global baz")
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, bar)
utilityService.provideUtility(IBaz, baz)
utilityService.provideUtility(IInterface, foo,
@@ -181,7 +181,7 @@
foo = Foo("global bob")
bar = Bar("global")
baz = Baz("global baz")
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, bar)
utilityService.provideUtility(IBaz, baz)
utilityService.provideUtility(IInterface, foo,
@@ -191,7 +191,7 @@
[foo])
def test_queryUtility_delegates_to_global(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, Foo("global"))
utilityService.provideUtility(IInterface, Foo("global bob"),
name="bob")
@@ -206,7 +206,7 @@
"foo global bob")
def test_getUtility_delegates_to_global(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, Foo("global"))
utilityService.provideUtility(IInterface, Foo("global bob"),
name="bob")
@@ -238,7 +238,7 @@
def test_local_utilities(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IInterface, Foo("global"))
utilityService.provideUtility(IInterface, Foo("global bob"),
name="bob")
Modified: Zope3/trunk/src/zope/app/security/tests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/__init__.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/security/tests/__init__.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -22,7 +22,7 @@
def addCheckerPublic():
"""Add the CheckerPublic permission as 'zope.Public'"""
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
perm = Permission('zope.Public', 'Public',
"""Special permission used for resources that are always public
Modified: Zope3/trunk/src/zope/app/site/tests/placefulsetup.py
===================================================================
--- Zope3/trunk/src/zope/app/site/tests/placefulsetup.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/site/tests/placefulsetup.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -70,7 +70,7 @@
def makeSite(self, path='/'):
folder = zapi.traverse(self.rootFolder, path)
- return setup.createServiceManager(folder)
+ return setup.createServiceManager(folder, True)
def createRootFolder(self):
self.rootFolder = rootFolder()
Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/tests/functional.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -37,7 +37,7 @@
from zope.app.publication.zopepublication import ZopePublication
from zope.app.publication.http import HTTPPublication
import zope.app.tests.setup
-from zope.thread import thread_globals
+from zope.app.component.hooks import setSite, getSite
__metaclass__ = type
@@ -169,11 +169,11 @@
def setSite(self, site):
"""Set the site which will be used to look up local services"""
- thread_globals().site = site
+ setSite(site)
def getSite(self):
"""Returns the site which is used to look up local services"""
- return thread_globals().site
+ return getSite()
def makeRequest(self, path='', basic=None, form=None, env={},
outstream=None):
Modified: Zope3/trunk/src/zope/app/tests/setup.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/setup.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/tests/setup.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -106,10 +106,11 @@
createServiceManager(site, setsite=True)
return site
+from zope.app.component.hooks import setSite
def placefulTearDown():
placelessTearDown()
zope.component.getServices.reset()
- thread_globals().site = None
+ setSite()
from zope.app.folder import Folder, rootFolder
@@ -141,12 +142,11 @@
from zope.app.site.service import ServiceManager
from zope.app.site.interfaces import ISite
-from zope.thread import thread_globals
def createServiceManager(folder, setsite=False):
if not ISite.providedBy(folder):
folder.setSiteManager(ServiceManager(folder))
if setsite:
- thread_globals().site = folder
+ setSite(folder)
return zapi.traverse(folder, "++etc++site")
from zope.app.site.service import ServiceRegistration
Modified: Zope3/trunk/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/__init__.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/undo/__init__.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -28,7 +28,7 @@
def undoSetup(event):
# setup undo functionality
- svc = zapi.getService(None, Utilities)
+ svc = zapi.getGlobalService(Utilities)
svc.provideUtility(IUndoManager, ZODBUndoManager(event.database))
undoSetup = function.Subscriber(undoSetup)
Modified: Zope3/trunk/src/zope/app/utility/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/utility/tests.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/app/utility/tests.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -89,7 +89,7 @@
utility.LocalUtilityService())
def test_queryUtility_delegates_to_global(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IFoo, Foo("global"))
utilityService.provideUtility(IFoo, Foo("global bob"),
name="bob")
@@ -117,7 +117,7 @@
self.assertEqual(utility_service.queryUtility(IFoo, name="rob"), None)
def test_getUtility_delegates_to_global(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IFoo, Foo("global"))
utilityService.provideUtility(IFoo, Foo("global bob"),
name="bob")
@@ -160,7 +160,7 @@
def test_local_utilities(self):
- utilityService = zapi.getService(None, zapi.servicenames.Utilities)
+ utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
utilityService.provideUtility(IFoo, Foo("global"))
utilityService.provideUtility(IFoo, Foo("global bob"),
name="bob")
Modified: Zope3/trunk/src/zope/component/__init__.py
===================================================================
--- Zope3/trunk/src/zope/component/__init__.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/component/__init__.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -48,6 +48,9 @@
def getGlobalServices():
return serviceManager
+def getGlobalService(name):
+ return serviceManager.getService(name)
+
def getServiceManager(context):
# Backwards compatibility stub
warnings.warn("getServiceManager(context) is deprecated,"
Modified: Zope3/trunk/src/zope/component/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/component/interfaces.py 2004-05-22 17:30:08 UTC (rev 24883)
+++ Zope3/trunk/src/zope/component/interfaces.py 2004-05-22 18:31:47 UTC (rev 24884)
@@ -28,6 +28,9 @@
def getGlobalServices():
"""Get the global service manager."""
+ def getGlobalService(name):
+ """Get a global service."""
+
def getServices(context=None):
"""Get the service manager
More information about the Zope3-Checkins
mailing list