[form] simply skip unknown argument given to form constructor, don't fail stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Sep 2009 12:52:44 +0200
branchstable
changeset 3340 7dfccf5612ed
parent 3339 d1d643ef37f7
child 3341 99c0b55892d6
child 3344 699949007fc2
[form] simply skip unknown argument given to form constructor, don't fail
web/views/forms.py
--- a/web/views/forms.py	Mon Sep 21 12:52:17 2009 +0200
+++ b/web/views/forms.py	Mon Sep 21 12:52:44 2009 +0200
@@ -82,9 +82,10 @@
         for key, val in kwargs.items():
             if key in NAV_FORM_PARAMETERS:
                 self.form_add_hidden(key, val)
-            else:
-                assert hasattr(self.__class__, key) and not key[0] == '_', key
+            elif hasattr(self.__class__, key) and not key[0] == '_':
                 setattr(self, key, val)
+            # skip other parameters, usually given for selection
+            # (else write a custom class to handle them)
         if mainform:
             self.form_add_hidden('__errorurl', self.session_key())
             self.form_add_hidden('__domid', self.domid)