[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms - Utility.py:1.6

Jim Fulton jim@zope.com
Mon, 9 Dec 2002 11:09:48 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms
In directory cvs.zope.org:/tmp/cvs-serv31486/lib/python/Zope/App/Forms

Modified Files:
	Utility.py 
Log Message:
Renamed widgets (changed the view name) from 'widget' to 'edit'.


=== Zope3/lib/python/Zope/App/Forms/Utility.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/App/Forms/Utility.py:1.5	Mon Nov 11 15:52:57 2002
+++ Zope3/lib/python/Zope/App/Forms/Utility.py	Mon Dec  9 11:09:18 2002
@@ -41,7 +41,7 @@
 from Zope.ComponentArchitecture.IView import IViewFactory
 
 
-def setUpWidget(view, name, field, value=None, prefix=None, force=0):
+def setUpWidget(view, name, field, value=None, prefix=None, force=0, vname=None):
     """Set up a single view widget
 
     The widget will be an attribute of the view. If there is already
@@ -58,7 +58,8 @@
     if widget is None:
         # There isn't already a widget, create one
         field = field.bind(view.context)
-        vname = getDefaultViewName(field, view.request)
+        if vname is None:
+            vname = getDefaultViewName(field, view.request)
         widget = getView(field, vname, view.request)
         setattr(view, name, widget)
 
@@ -124,8 +125,13 @@
         field = schema[name]
         if IField.isImplementedBy(field):
             # OK, we really got a field
+            if field.readonly:
+                vname = 'display'
+            else:
+                vname = 'edit'
+                
             setUpWidget(view, name, field, getattr(content, name, None),
-                        prefix = prefix, force = force)
+                        prefix = prefix, force = force, vname = vname)
 
 def haveWidgetsData(view, schema):
     """Collect the user-entered data defined by a schema