[Zope3-checkins] CVS: Zope3/src/zope/app/form - utility.py:1.16

Jim Fulton jim@zope.com
Mon, 14 Apr 2003 04:27:46 -0400


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

Modified Files:
	utility.py 
Log Message:
Updated the form-genmeration software to support accessors. Mainly
this involved changing the software to use field ``get``, ``query``,
and ``set`` methods rather than attribute access.  Also modified the
tests to test accessor usage.

Fixed adapter support. Now edit views store the adapted context
separately from the context. Also, edit and add views use getApter
rather than queryAdapter to get adapters. The previous uses of
queryAdapter were hiding some logic errors.  Added unit tests!
In the course of adding unit tests, I discovered an issue relating to
event generation. Normally, we generate an ObjectModification event
when we edit something, however, it's not so clear what we should do
in the presense of an adapter. I finally decided that we should not
generate an event if the object was adapted. In that case, the adapter
should generate any necessary events.


=== Zope3/src/zope/app/form/utility.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/form/utility.py:1.15	Fri Mar  7 16:27:32 2003
+++ Zope3/src/zope/app/form/utility.py	Mon Apr 14 04:27:16 2003
@@ -139,7 +139,7 @@
             vname = 'edit'
 
         try:
-            value = getattr(content, name)
+            value = field.get(content)
         except AttributeError, v:
             if v.__class__ != AttributeError:
                 raise
@@ -221,10 +221,10 @@
 def getWidgetsDataForContent(view, schema, content=None, strict=True,
                              names=None, set_missing=True):
     """Collect the user-entered data defined by a schema
-
+    
     Data is collected from view widgets. For every field in the
     schema, we look for a view of the same name and get it's data.
-
+    
     The data are assigned to the given content object.
 
     If the strict argument is true, then if some required data are
@@ -250,7 +250,8 @@
 
     for name in data:
         try:
-            setattr(content, name, data[name])
+            field = schema[name]
+            field.set(content, data[name])
         except ValidationError, v:
             errors.append(v)