[Zope3-checkins] CVS: Zope3/src/zope/app/services - configure.zcml:1.15.2.1 service.py:1.8.4.1

Tim Peters tim.one@comcast.net
Mon, 24 Feb 2003 17:44:44 -0500


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

Modified Files:
      Tag: use-config-branch
	configure.zcml service.py 
Log Message:
Changed service registrations to record their uses.  Added
manage_afterAdd() and manage_beforeDelete() overrides to
ServiceConfiguration.  In zope/app/services/configure.zcml, changed
services to provide IUseConfiguration.


=== Zope3/src/zope/app/services/configure.zcml 1.15 => 1.15.2.1 ===
--- Zope3/src/zope/app/services/configure.zcml:1.15	Fri Feb  7 10:52:21 2003
+++ Zope3/src/zope/app/services/configure.zcml	Mon Feb 24 17:44:44 2003
@@ -14,7 +14,7 @@
 
 <content class="zope.app.services.adapter.AdapterService">
   <implements
-      interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+      interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
       />
   <factory
       id="zope.app.services.AdapterService"
@@ -43,7 +43,7 @@
 
 <content class="zope.app.services.view.ViewService">
   <implements
-      interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
+      interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable" />
   <factory
       id="zope.app.services.ViewService"
       permission="zope.ManageServices"
@@ -102,27 +102,33 @@
       />
 </content>
 
-<adapter 
+<adapter
   for="zope.app.interfaces.services.interfaces.IZPTTemplate"
   provides="zope.app.interfaces.file.IReadFile"
   factory=".zpt.ReadFile"
   permission="zope.ManageServices"
   />
 
-<adapter 
+<adapter
   for="zope.app.interfaces.services.interfaces.IZPTTemplate"
   provides="zope.app.interfaces.file.IWriteFile"
   factory=".zpt.WriteFile"
   permission="zope.ManageServices"
   />
 
-<adapter 
+<adapter
   for="zope.app.interfaces.services.service.IViewPackage"
   provides="zope.app.interfaces.file.IFileFactory"
   factory=".zpt.ZPTFactory"
   permission="zope.ManageServices"
   />
 
+<adapter
+  for="zope.app.interfaces.services.configuration.IUseConfigurable"
+  provides="zope.app.interfaces.services.configuration.IUseConfiguration"
+  factory="zope.app.services.configuration.UseConfiguration"
+  />
+
 <!-- Role Templates -->
 
 <content class="zope.app.services.role.RoleService">
@@ -139,7 +145,7 @@
       interface="zope.app.interfaces.container.IContainer"
       />
   <implements
-      interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+      interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
       />
 </content>
 
@@ -154,7 +160,7 @@
 <!-- Session Templates -->
 
 <serviceType
-    id="Sessions" 
+    id="Sessions"
     interface="zope.app.interfaces.services.session.ISessionService"
     />
 
@@ -168,7 +174,7 @@
       permission="zope.ManageServices"
       />
   <implements
-      interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+      interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
       />
 </content>
 
@@ -185,7 +191,7 @@
           permission="zope.ManageServices"
           interface="zope.app.interfaces.container.IContainer" />
       <implements
-          interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
+          interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable" />
     </content>
 
   <content class="zope.app.services.cache.CacheConfiguration">
@@ -299,7 +305,7 @@
         interface="zodb.code.interfaces.IPersistentModuleManager"
         />
     <implements
-        interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+        interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
         />
     </content>
 
@@ -307,9 +313,9 @@
 
   <content class="zope.app.services.viewpackage.ViewPackage">
     <factory
-      id = "zope.app.services.ViewPackage" 
+      id = "zope.app.services.ViewPackage"
       permission = "zope.ManageServices"
-      title = "View Package" 
+      title = "View Package"
       />
     <require
         permission="zope.View"
@@ -333,10 +339,10 @@
   <content class="zope.app.services.connection.ConnectionService">
     <factory
        id="ConnectionService"
-       permission="zope.ManageServices" 
+       permission="zope.ManageServices"
        />
     <implements
-       interface="zope.app.interfaces.annotation.IAttributeAnnotatable" 
+       interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
        />
     <require
         permission="zope.View"
@@ -351,15 +357,15 @@
         interface=
         "zope.app.interfaces.services.connection.IConnectionConfiguration"
         set_attributes="name componentPath"
-        set_schema="zope.app.interfaces.services.interfaces.IPageConfiguration" 
+        set_schema="zope.app.interfaces.services.interfaces.IPageConfiguration"
         />
     <require
         permission="zope.ManageServices"
-        interface="zope.app.interfaces.container.IAddNotifiable" 
+        interface="zope.app.interfaces.container.IAddNotifiable"
         />
     <require
         permission="zope.ManageServices"
-        interface="zope.app.interfaces.container.IDeleteNotifiable" 
+        interface="zope.app.interfaces.container.IDeleteNotifiable"
         />
     </content>
 
@@ -384,15 +390,15 @@
         id="IPrincipalAnnotationService"
         permission="zope.ManageServices"
         />
-    <implements 
-       interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+    <implements
+       interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
        />
     </content>
 
 <!-- Error reporting service -->
 
   <serviceType
-      id="ErrorReportingService" 
+      id="ErrorReportingService"
       interface="zope.app.interfaces.services.error.IErrorReportingService" />
 
   <content class='zope.app.services.errorr.ErrorReportingService'>
@@ -404,14 +410,14 @@
         id='ErrorReportingService'
         permission='zope.Public' />
     <implements
-        interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+        interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable"
         />
     </content>
 
 <!-- Object Hub -->
 
   <serviceType
-      id='HubIds' 
+      id='HubIds'
       interface='zope.app.interfaces.services.hub.IObjectHub' />
 
   <content class='zope.app.services.hub.ObjectHub'>
@@ -422,13 +428,13 @@
         permission="zope.View"
 	attributes="notify getHubId getLocation getObject
                     register unregister numRegistrations
-                    getRegistrations" />		   
+                    getRegistrations" />
     <require
         permission="zope.ManageServices"
         attributes="bound unbound subscribe unsubscribe subscribeOnBind
                     unsubscribedFrom subscribedTo" />
-    <implements 
-       interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
+    <implements
+       interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable" />
     </content>
 
 <!-- Authentication Service -->
@@ -451,7 +457,7 @@
         interface="zope.app.interfaces.container.IContainer" />
 
     <implements
-       interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
+       interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable" />
 
     </content>
 
@@ -483,7 +489,7 @@
                   unsubscribedFrom subscribedTo"
       />
   <implements
-      interface="zope.app.interfaces.annotation.IAttributeAnnotatable."
+      interface="zope.app.interfaces.services.configuration.IAttributeUseConfigurable."
       />
 </content>
 


=== Zope3/src/zope/app/services/service.py 1.8 => 1.8.4.1 ===
--- Zope3/src/zope/app/services/service.py:1.8	Tue Feb  4 05:26:00 2003
+++ Zope3/src/zope/app/services/service.py	Mon Feb 24 17:44:44 2003
@@ -31,6 +31,7 @@
 from zodb.code.module import PersistentModule
 from zodb.code.module import PersistentModuleRegistry
 
+from zope.component import getAdapter
 from zope.component import getServiceManager
 from zope.component.exceptions import ComponentLookupError
 from zope.component.interfaces import IServiceService
@@ -48,6 +49,7 @@
 from zope.app.interfaces.services.service import IServiceConfiguration
 from zope.app.interfaces.services.service import IServiceManager
 from zope.app.interfaces.services.service import IServiceManagerContainer
+from zope.app.interfaces.services.configuration import IUseConfiguration
 
 ModuleType = type(INameResolver)
 ModuleType = ModuleType, PersistentModule
@@ -57,6 +59,8 @@
 from zope.app.services.configuration import NamedComponentConfiguration
 from zope.app.services.package import Packages
 
+from zope.app.traversing import getPhysicalPathString
+
 class ServiceManager(PersistentModuleRegistry, NameComponentConfigurable):
 
     __implements__ = (IServiceManager, IReadContainer,
@@ -279,3 +283,18 @@
 
     deactivated = ContextMethod(deactivated)
 
+    def manage_afterAdd(self, configuration, container):
+        NamedComponentConfiguration.manage_afterAdd(self,
+                                                    configuration,
+                                                    container)
+        service = configuration.getComponent()
+        adapter = getAdapter(service, IUseConfiguration)
+        adapter.addUsage(getPhysicalPathString(configuration))
+
+    def manage_beforeDelete(self, configuration, container):
+        service = configuration.getComponent()
+        adapter = getAdapter(service, IUseConfiguration)
+        adapter.removeUsage(getPhysicalPathString(configuration))
+        NamedComponentConfiguration.manage_beforeDelete(self,
+                                                        configuration,
+                                                        container)