[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/utility - configure.zcml:1.1.2.4 useconfiguration.py:1.1.2.4 addconfiguration.pt:NONE

Guido van Rossum guido@python.org
Tue, 18 Mar 2003 16:10:33 -0500


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

Modified Files:
      Tag: local-utility-branch
	configure.zcml useconfiguration.py 
Removed Files:
      Tag: local-utility-branch
	addconfiguration.pt 
Log Message:
Another checkpoint.

=== Zope3/src/zope/app/browser/services/utility/configure.zcml 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/browser/services/utility/configure.zcml:1.1.2.3	Tue Mar 18 11:55:44 2003
+++ Zope3/src/zope/app/browser/services/utility/configure.zcml	Tue Mar 18 16:10:02 2003
@@ -27,6 +27,16 @@
       content_factory="zope.app.services.utility.UtilityConfiguration"
       arguments="name interface componentPath"
       set_after_add="status"
+      fields="name interface componentPath permission status"
+      />
+
+  <editform
+      name="index.html"
+      menu="zmi_views" title="Edit"
+      schema="zope.app.interfaces.services.utility.IUtilityConfiguration"
+      label="Utility Configuration"
+      permission="zope.ManageServices"
+      fields="name interface componentPath permission status"
       />
            
 


=== Zope3/src/zope/app/browser/services/utility/useconfiguration.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/browser/services/utility/useconfiguration.py:1.1.2.3	Tue Mar 18 11:55:44 2003
+++ Zope3/src/zope/app/browser/services/utility/useconfiguration.py	Tue Mar 18 16:10:02 2003
@@ -16,25 +16,20 @@
 $Id$
 """
 
-from zope.component import getAdapter, getView, getServiceManager
+from zope.component import getAdapter, getView
 from zope.app.interfaces.services.configuration import IUseConfiguration
 from zope.app.traversing import traverse, getPhysicalPathString
 from zope.publisher.browser import BrowserView
 from zope.interface.implements import flattenInterfaces
-from zope.app.services.utility import UtilityConfiguration
 from zope.proxy.introspection import removeAllProxies
 from zope.proxy.context import getWrapperContainer
 from zope.app.interfaces.container import IZopeContainer
-from zope.app.interfaces.services.utility import IUtilityConfiguration
-from zope.app.form.utility import setUpWidgets
 from zope.app.form.widget import CustomWidget
-from zope.app.browser.component.interfacewidget import InterfaceWidget
 from zope.app.browser.services.field import ComponentPathDisplayWidget
 
 class UseConfiguration(BrowserView):
-    """View for displaying the configurations for a utility
+    """View for displaying the configurations for a utility.
     """
-    
 
     def uses(self):
         """Get a sequence of configuration summaries
@@ -55,14 +50,22 @@
         
 
 class AddConfiguration:
-    """View for adding a utility configuration
+    """View for adding a utility configuration.
+
+    This overrides some methods from IAddFormCustomization.
+
+    This is a view on a local utility, configured by an <addform>
+    directive.
     """
 
-    interface = CustomWidget(InterfaceWidget)
+    # Override the default widget choice for componentPath
     componentPath = CustomWidget(ComponentPathDisplayWidget)
 
     def beforeUpdateHook(self):
+        # XXX Have to remove proxies because flattenInterfaces
+        #     doesn't work with proxies.
         bare = removeAllProxies(self.context)
+        # Tell the interface widget which interfaces the user can select
         self.interface.interfaces = [
             interface
             for interface in flattenInterfaces(bare.__implements__)
@@ -70,15 +73,21 @@
             ]
 
         path = getPhysicalPathString(self.context)
+        # XXX Poke the data we want into the request so when the widget's
+        #     getData() later looks in the request it will see the
+        #     right thing.  We can't use setData() because it has a
+        #     different meaning (sets the *default* data to display).
         self.request.form[self.componentPath.name] = path
         #self.componentPath.setData(path)
         
     def add(self, content):
         # Get the configuration manager for this folder
         configure = traverse(getWrapperContainer(self.context), 'configure')
+        # Adapt to IZopeContainer, which takes care of generating
+        # standard events and calling standard hooks
         container = getAdapter(configure, IZopeContainer)
-        return container[container.setObject("", content)]
+        key = container.setObject("", content)
+        return container[key]
 
     def nextURL(self):
         return "@@useConfiguration.html"
-

=== Removed File Zope3/src/zope/app/browser/services/utility/addconfiguration.pt ===