[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - add.py:1.23

Marius Gedminas mgedmin@codeworks.lt
Mon, 23 Jun 2003 12:42:20 -0400


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

Modified Files:
	add.py 
Log Message:
Do not accept optional fields as positional arguments in add forms (otherwise
you'll get an exception when the user submits the form without filling them
in).


=== Zope3/src/zope/app/browser/form/add.py 1.22 => 1.23 ===
--- Zope3/src/zope/app/browser/form/add.py:1.22	Wed Apr 30 15:36:23 2003
+++ Zope3/src/zope/app/browser/form/add.py	Mon Jun 23 12:41:49 2003
@@ -200,6 +200,11 @@
         if missing:
             raise ValueError("Some arguments are not included in the form",
                              missing)
+        optional = [n for n in arguments if not schema[n].required]
+        if optional:
+            raise ValueError("Some arguments are optional, use"
+                             " keyword_arguments for them",
+                             optional)
         leftover = [n for n in leftover if n not in arguments]
 
     if keyword_arguments: