[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/app/schema/ Replaced the custom registration with subscribers that set or clear

Jim Fulton jim at zope.com
Tue Apr 18 19:55:31 EDT 2006


Log message for revision 67089:
  Replaced the custom registration with subscribers that set or clear
  the definition names.
  
  Note that there weren't tests for the registration, so I didn't write
  tests for the subscribers. :)
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/app/schema/configure.zcml
  U   Zope3/branches/jim-adapter/src/zope/app/schema/schema.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/schema/configure.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/schema/configure.zcml	2006-04-18 23:55:28 UTC (rev 67088)
+++ Zope3/branches/jim-adapter/src/zope/app/schema/configure.zcml	2006-04-18 23:55:30 UTC (rev 67089)
@@ -17,12 +17,8 @@
 
   </localUtility>
 
-  <class class=".schema.SchemaRegistration">
-    <require
-      permission="zope.ManageServices"
-      interface="zope.app.component.interfaces.IUtilityRegistration"
-      set_schema="zope.app.component.interfaces.IUtilityRegistration" />
-  </class>
+  <subscriber handler=".schema.schemaUtilityRegistered" />
+  <subscriber handler=".schema.schemaUtilityUnregistered" />
 
   <include file="fields.zcml" />
   <include package=".browser" />

Modified: Zope3/branches/jim-adapter/src/zope/app/schema/schema.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/schema/schema.py	2006-04-18 23:55:28 UTC (rev 67088)
+++ Zope3/branches/jim-adapter/src/zope/app/schema/schema.py	2006-04-18 23:55:30 UTC (rev 67089)
@@ -20,13 +20,13 @@
 from persistent import Persistent
 from persistent.dict import PersistentDict
 from zope.interface import Interface, implements
+import zope.component.interfaces
 
 from zope.security.proxy import removeSecurityProxy
 from zope.proxy import removeAllProxies
 from zope.app import zapi
 from zope.app.container.browser.adding import Adding
 from zope.app.interface import PersistentInterfaceClass
-from zope.app.component.site import UtilityRegistration
 from zope.app.container.contained import Contained, setitem, uncontained
 
 from zope.interface.interface import Attribute, Method, fromFunction
@@ -266,18 +266,21 @@
 
     def nextURL(self):
         """See zope.app.container.interfaces.IAdding"""
-        return zapi.absoluteURL(self.context, self.request)+'/@@editschema.html'
+        return zapi.absoluteURL(self.context,
+                                self.request,
+                                )+'/@@editschema.html'
 
 
-class SchemaRegistration(UtilityRegistration):
-    """Schema Registration
+ at zope.component.adapter(
+    ISchemaUtility,
+    zope.component.interfaces.IRegistered,
+    )
+def schemaUtilityRegistered(schema, event):
+    schema.setName(event.object.name)
 
-    We have a custom registration here, since we want active registrations to
-    set the name of the schema.
-    """
-
-    def activated(self):
-        self.component.setName(self.name)
-
-    def deactivated(self):
-        self.component.setName('<schema not activated>')
+ at zope.component.adapter(
+    ISchemaUtility,
+    zope.component.interfaces.IUnregistered,
+    )
+def schemaUtilityUnregistered(schema, event):
+    schema.setName('<schema not activated>')



More information about the Zope3-Checkins mailing list