[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - add.py:1.30 configure.zcml:1.22 edit.pt:1.11 editview.py:1.35 widget.py:1.50

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Aug 15 21:44:56 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv20171/app/browser/form

Modified Files:
	add.py configure.zcml edit.pt editview.py widget.py 
Log Message:
Merging dreamcatcher's TTW Schema branch:

1. Fixed Bug in adding that would cause infinite loops when the menu items
   action was not a valif view or factory id.

2. Extended adding to support more complex views. Until now we only 
   supported constructions like "+/AddView=id". Now you are able to say
   "+/AddView/More=id", which means that more information can be carried 
   in the URL. This can be used in many ways, including multi-page adding
   wizards. In my case I needed it to pass in the type of the TTW Schema-
   based Content Component.

3. Added Local Menus. This was a pain in the butt, but I think I got a 
   fairly nice model, where you can create local Menu Services, and Menus
   are simply named utilities. When active they are menus in the menu 
   service. This is very similar to the local interface service and TTW 
   Schema. 

4. Made some modifications to TTW Schema, cleaned up the code and moved
   the browser code and interfaces to the places they belong.

5. Added a Content Component Definition utility component, which takes a
   Schema and creates a content component for it, including permission
   settings and a menu entry. Currently the menu entry is always made to
   a local 'add_content' menu. I will change this and make it actually a
   screen, where the menu and title of the menu item can be chosen by the
   developer. Mmmh, should I add a factory for the definition as well, so
   that the content component is also available via python?

6. Added a Content Component Instance component that represents an 
   instance od a Content Component Definition. You will never directly 
   encounter this component, since it is automatically used by the adding
   code of the Content Component Definition.

7. Cleanups by both dreamcatcher and myself.

That's it. For more details see the branch checkin messages. I now consider
the dreamcatcher-ttwschema-branch closed.


=== Zope3/src/zope/app/browser/form/add.py 1.29 => 1.30 ===
--- Zope3/src/zope/app/browser/form/add.py:1.29	Thu Aug  7 13:40:28 2003
+++ Zope3/src/zope/app/browser/form/add.py	Fri Aug 15 20:42:49 2003
@@ -75,7 +75,7 @@
 
         The data argument is a dictionary with the data entered in the form.
         """
-        
+
         args = []
         if self._arguments:
             for name in self._arguments:


=== Zope3/src/zope/app/browser/form/configure.zcml 1.21 => 1.22 ===
--- Zope3/src/zope/app/browser/form/configure.zcml:1.21	Tue Aug 12 14:18:02 2003
+++ Zope3/src/zope/app/browser/form/configure.zcml	Fri Aug 15 20:42:49 2003
@@ -5,6 +5,18 @@
   <!-- Form Widget View Directives -->
   <browser:defaultView for="zope.schema.interfaces.IField" name="edit" />
 
+  <!-- XXX The next directive should be replaced by one that 
+       uses a 'smart' widget that knows how to deal with type-agnostic
+       values, which is the porpose of zope.schema.Field -->
+
+  <browser:page
+      permission="zope.Public"
+      allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"
+      for="zope.schema.interfaces.IField"
+      name="edit"
+      class="zope.app.browser.form.widget.BrowserWidget"
+      />
+
   <browser:page
       permission="zope.Public"
       allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"


=== Zope3/src/zope/app/browser/form/edit.pt 1.10 => 1.11 ===
--- Zope3/src/zope/app/browser/form/edit.pt:1.10	Thu Aug  7 13:40:28 2003
+++ Zope3/src/zope/app/browser/form/edit.pt	Fri Aug 15 20:42:49 2003
@@ -24,6 +24,10 @@
                               i18n:name="num_errors">6</strong> input errors.
         </p>
 
+        <tal:block repeat="error view/errors">
+          <div class="error" tal:content="error">error</div>
+        </tal:block>
+
         <div metal:define-slot="extra_info" tal:replace="nothing">
         </div>
 


=== Zope3/src/zope/app/browser/form/editview.py 1.34 => 1.35 ===
--- Zope3/src/zope/app/browser/form/editview.py:1.34	Thu Aug  7 13:40:28 2003
+++ Zope3/src/zope/app/browser/form/editview.py	Fri Aug 15 20:42:49 2003
@@ -47,6 +47,8 @@
 
     # Fall-back field names computes from schema
     fieldNames = property(lambda self: getFieldNamesInOrder(self.schema))
+    # Fall-back template
+    generated_form = ViewPageTemplateFile('edit.pt')
 
     def __init__(self, context, request):
         super(EditView, self).__init__(context, request)


=== Zope3/src/zope/app/browser/form/widget.py 1.49 => 1.50 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.49	Wed Aug 13 17:27:50 2003
+++ Zope3/src/zope/app/browser/form/widget.py	Fri Aug 15 20:42:49 2003
@@ -95,7 +95,7 @@
     >>> print widget.label()
     <label for="test.foo">Foo</label>
     >>> tearDown()
-    
+
     """
 
     implements(IBrowserWidget)
@@ -318,7 +318,7 @@
     1
     >>> int(widget.getInputValue())
     1
-    
+
     >>> def normalize(s):
     ...   return '\\n  '.join(s.split())
 
@@ -427,7 +427,7 @@
     1
     >>> widget.getInputValue()
     u'Bob'
-    
+
     >>> def normalize(s):
     ...   return '\\n  '.join(filter(None, s.split(' ')))
 
@@ -503,7 +503,7 @@
 
 
     def __call__(self):
-        if self.__values is not None:
+        if self.__values:
             return self._select()
 
         displayMaxWidth = self.getValue('displayMaxWidth') or 0
@@ -616,7 +616,7 @@
     """TextArea widget.
 
     Multi-line text (unicode) input.
-    
+
     >>> from zope.publisher.browser import TestRequest
     >>> from zope.schema import Text
     >>> field = Text(__name__='foo', title=u'on')
@@ -626,7 +626,7 @@
     1
     >>> widget.getInputValue()
     u'Hello\\nworld!'
-    
+
     >>> def normalize(s):
     ...   return '\\n  '.join(filter(None, s.split(' ')))
 
@@ -680,7 +680,7 @@
         value = super(TextAreaWidget, self)._unconvert(value)
         if value:
             value = value.replace("\n", "\r\n")
-        return value        
+        return value
 
     def __call__(self):
         return renderElement("textarea",
@@ -697,7 +697,7 @@
     """BytesArea widget.
 
     Multi-line text (unicode) input.
-    
+
     >>> from zope.publisher.browser import TestRequest
     >>> from zope.schema import Bytes
     >>> field = Bytes(__name__='foo', title=u'on')
@@ -828,8 +828,8 @@
     def renderItems(self, value):
         name = self.name
         # get items
-        items = self.context.allowed_values        
-        
+        items = self.context.allowed_values
+
         # check if we want to select first item
         if (not value and getattr(self.context, 'firstItem', False)
             and len(items) > 0):
@@ -1090,7 +1090,7 @@
             widget = self._getWidget(i)
             widget.setRenderedValue(value)
             r(widget()+'</td></tr>')
-            
+
         # possibly generate the "remove" and "add" buttons
         s = ''
         if render and num_items > min_length:
@@ -1190,7 +1190,7 @@
             return []
         field = self.context.value_type
 
-        # pre-populate 
+        # pre-populate
         found = {}
         for i in range(len(self._data)):
             entry = self._data[i]
@@ -1220,7 +1220,7 @@
                 value = widget.getInputValue()
                 found[i] = value
 
-        # remove the indicated indexes 
+        # remove the indicated indexes
         for i in  removing:
             del found[i]
 
@@ -1292,7 +1292,7 @@
         for name, widget in self.getSubWidgets():
             r(widget.row())
         r('</fieldset>')
-            
+
         return '\n'.join(render)
 
     def getSubWidgets(self):
@@ -1432,4 +1432,4 @@
     global tearDown
     tearDown = zope.app.tests.placelesssetup.tearDown
     tearDown()
-    
+




More information about the Zope3-Checkins mailing list