[Zope3-checkins] CVS: Zope3/src/zope/app/utilities - configure.zcml:1.1.2.5 schema.py:1.1.2.10

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Aug 13 12:44:11 EDT 2003


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

Modified Files:
      Tag: dreamcatcher-ttwschema-branch
	configure.zcml schema.py 
Log Message:
Finished Registration changes.

TODO:

- Currently it is possible for more than one registration to be active. This
  should not be possible! I don't know whether this is a Zope or
  UtilityRegistration bug.


=== Zope3/src/zope/app/utilities/configure.zcml 1.1.2.4 => 1.1.2.5 ===
--- Zope3/src/zope/app/utilities/configure.zcml:1.1.2.4	Wed Aug 13 10:42:18 2003
+++ Zope3/src/zope/app/utilities/configure.zcml	Wed Aug 13 11:44:05 2003
@@ -47,15 +47,25 @@
 
   </content>
 
+  
+  <content class=".schema.SchemaRegistration">
+    <require
+      permission="zope.ManageServices"
+      interface="zope.app.interfaces.services.utility.IUtilityRegistration
+                 zope.app.interfaces.container.IAddNotifiable
+                 zope.app.interfaces.container.IDeleteNotifiable"
+      set_schema="zope.app.interfaces.services.utility.IUtilityRegistration"
+      />
+  </content>
 
   <browser:addform
       label="New Mutable Schema Registration"
       for="zope.app.interfaces.utilities.ISchemaUtility"
       name="addRegistration.html"
       schema="zope.app.interfaces.services.utility.IUtilityRegistration"
-      class=".schema.AddSchemaRegistration"
+      class="zope.app.browser.services.utility.AddRegistration"
       permission="zope.ManageServices"
-      content_factory="zope.app.services.utility.UtilityRegistration"
+      content_factory=".schema.SchemaRegistration"
       arguments="name interface componentPath"
       set_after_add="status"
       fields="name interface componentPath permission status" />


=== Zope3/src/zope/app/utilities/schema.py 1.1.2.9 => 1.1.2.10 ===
--- Zope3/src/zope/app/utilities/schema.py:1.1.2.9	Wed Aug 13 11:38:31 2003
+++ Zope3/src/zope/app/utilities/schema.py	Wed Aug 13 11:44:05 2003
@@ -16,25 +16,26 @@
 $Id$
 """
 from zope.app import zapi
-from zope.component import getAdapter
+from zope.app.browser.container.adding import Adding
+from zope.app.browser.form.editview import EditView
 from zope.app.context import ContextWrapper
-from zope.interface import implements
-from zope.app.form.utility import setUpEditWidgets, \
-     applyWidgetsChanges, setUpWidget
+from zope.app.form.utility import \
+     setUpEditWidgets, applyWidgetsChanges, setUpWidget
 from zope.app.security.permission import PermissionField
 from zope.security.checker import CheckerPublic, Checker
-from zope.security.proxy import Proxy
-from zope.proxy import removeAllProxies
-from zope.app.browser.container.adding import Adding
-from zope.app.browser.form.editview import EditView
+from zope.security.proxy import Proxy, trustedRemoveSecurityProxy
 from zope.app.browser.form.submit import Update
 from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.app.interfaces.utilities import ISchemaAdding
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.app.services.interface import PersistentInterfaceClass
 from zope.app.services.interface import PersistentInterface
+from zope.app.services.utility import UtilityRegistration
 from zope.app.interfaces.utilities import IMutableSchema, ISchemaUtility
+from zope.component import getAdapter
+from zope.context import ContextMethod
 from zope.interface import implements
+from zope.proxy import removeAllProxies
 from zope.publisher.browser import BrowserView
 from zope.schema import getFieldsInOrder, getFieldNamesInOrder
 from zope.security.proxy import trustedRemoveSecurityProxy
@@ -261,11 +262,20 @@
                 + '/@@editschema.html')
 
 
-from zope.app.browser.services.utility import AddRegistration
+class SchemaRegistration(UtilityRegistration):
+    """Schema Registration
 
-class AddSchemaRegistration(AddRegistration):
+    We have a custom registration here, since we want active registrations to
+    set the name of the schema.
+    """
+    
+    def activated(self):
+        schema = self.getComponent()
+        schema.setName(self.name)
+    activated = ContextMethod(activated)
+        
+    def deactivated(self):
+        schema = self.getComponent()
+        schema.setName('<schema not activated>')
+    deactivated = ContextMethod(deactivated)
 
-    def add(self, registration):
-        reg = super(AddSchemaRegistration, self).add(registration)
-        self.context.setName(registration.name)
-        return reg




More information about the Zope3-Checkins mailing list