[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_cachingservice.py:1.13 test_cacheregistration.py:NONE

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Aug 19 14:34:36 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv19346/services/tests

Modified Files:
	test_cachingservice.py 
Removed Files:
	test_cacheregistration.py 
Log Message:
Just to make it worth the effort, here is the rewrite of the Caching Service
to use local utilities. I am amazed how much cruft can go away. There are
still some dead chickens left that can be easily fixed by providing a 
default overview screen for these services and remodeling the local utility
service a bit.

Jim,

noone has complained about the changes yet. Are you guys at ZC having a fit
with it? I think in general people just not use these components heavily
yet and it is no big deal to create them, since their data does not contain
much programming logic (i.e. they are easily recreated) and there are only
a few around ata time usually.


=== Zope3/src/zope/app/services/tests/test_cachingservice.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/services/tests/test_cachingservice.py:1.12	Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/test_cachingservice.py	Tue Aug 19 13:34:28 2003
@@ -17,17 +17,19 @@
 """
 
 from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app.tests import setup
-from zope.interface.verify import verifyObject
-from zope.interface import implements
-from zope.app.interfaces.cache.cache import ICache
-from zope.app.interfaces.cache.cache import ICachingService
-from zope.app.services.cache import CacheRegistration
+from zope.app import zapi
+from zope.app.interfaces.annotation import IAttributeAnnotatable
+from zope.app.interfaces.cache import ICache, ICachingService
 from zope.app.interfaces.services.registration import RegisteredStatus
 from zope.app.interfaces.services.registration import ActiveStatus
+from zope.app.services.cache import CachingService
+from zope.app.services.servicenames import Caching, Utilities
 from zope.app.services.tests.eventsetup import EventSetup
+from zope.app.services.utility import LocalUtilityService, UtilityRegistration
+from zope.app.tests import setup
 from zope.app.traversing import getPath, traverse
-from zope.app.interfaces.annotation import IAttributeAnnotatable
+from zope.interface import implements
+from zope.interface.verify import verifyObject
 
 def sort(list):
     list.sort()
@@ -49,14 +51,14 @@
 class CachingServiceSetup(EventSetup):
 
     def createCachingService(self, path=None):
-        from zope.app.services.cache import CachingService
-
         sm = self.makeSite(path)
-        return setup.addService(sm, "Caching", CachingService())
+        setup.addService(sm, Utilities, LocalUtilityService())
+        return setup.addService(sm, Caching, CachingService())
 
         return service
 
-    def addCache(self, name, cache=None, cname=None, status=ActiveStatus, folder=''):
+    def addCache(self, name, cache=None, cname=None, status=ActiveStatus,
+                 folder=''):
         if not cache:
             cache = CacheStub("%s/%s" % (folder, name))
         if not cname:
@@ -64,16 +66,19 @@
         default = traverse(self.rootFolder, folder +'/++etc++site/default')
         key = default.setObject(cname, cache)
         cache = traverse(default, key)
-        configure = default.getRegistrationManager()
-        key = configure.setObject('', CacheRegistration(name, getPath(cache)))
-        traverse(configure, key).status = status
-        return cache
+        path = "%s/%s" % (zapi.getPath(default), name)
+        registration = UtilityRegistration(name, ICache, path)
+        key = default.getRegistrationManager().setObject("", registration)
+        zapi.traverse(default.getRegistrationManager(), key).status = status
+        return zapi.traverse(default, name)    
 
 
 class TestCachingService(CachingServiceSetup, TestCase):
 
     def setUp(self):
         CachingServiceSetup.setUp(self)
+
+
         self.service = self.createCachingService()
         self.cache1 = self.addCache('cache1')
         self.cache2 = self.addCache('cache2')

=== Removed File Zope3/src/zope/app/services/tests/test_cacheregistration.py ===




More information about the Zope3-Checkins mailing list