Issue 30 in formalchemy: Key Error in AbstractField._validate [with patch]

2 views
Skip to first unread message

codesite...@google.com

unread,
Oct 12, 2008, 5:42:23 PM10/12/08
to forma...@googlegroups.com
Issue 30: Key Error in AbstractField._validate [with patch]
http://code.google.com/p/formalchemy/issues/detail?id=30

New issue report by andriod:
What steps will reproduce the problem?
1. Create a form with radio buttons, or alternately exclude a control from
the form on creation
2. do not set any value for the radio buttons
3. validate the form using a fieldset that includes the radio buttons or
excluded field.

What is the expected output? What do you see instead?
Form processes, no value is set for the missing fields. Instead KeyError
is thrown, trace:

File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/sushibar/controllers/displaygroups.py',
line 77 in update
return self.create()
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/sushibar/controllers/displaygroups.py',
line 29 in create
if(c.fs.validate()):
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/formalchemy/forms.py',
line 288 in validate
return AbstractFieldSet.validate(self)
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/formalchemy/forms.py',
line 71 in validate
success = field._validate() and success
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/formalchemy/fields.py',
line 541 in _validate
value = self._deserialize()
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/formalchemy/fields.py',
line 967 in _deserialize
return self.renderer.deserialize()
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/formalchemy/fields.py',
line 130 in deserialize
return self._deserialize(self._serialized_value())
File
'/home/andriod/WasabeWorkspace/SushiBar/SushiBar/formalchemy/fields.py',
line 110 in _serialized_value
return self._params.getone(self.name)
File
'/usr/lib/python2.5/site-packages/Paste-1.4.2-py2.5.egg/paste/util/multidict.py',
line 281 in getone
return self._decode_value(self.multi.getone(key))
File
'/usr/lib/python2.5/site-packages/Paste-1.4.2-py2.5.egg/paste/util/multidict.py',
line 68 in getone
raise KeyError('Key not found: %r' % key)
KeyError: "Key not found: 'DisplayGroup--DefaultSlideID'"


What version of the product are you using? On what operating system?
SVN trunk r516 SQLAlchemy-0.5.0beta3 Pylons-0.9.6.2


Please provide any additional information below.
I suggest fixing this by surrounding line 110 in _serialized_value:
return self._params.getone(self.name)
with a try clause like this:

try:
return self._params.getone(self.name)
except:
return None

thus, in the event of any error getting the value it is treated as blank.

Issue attributes:
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Oct 12, 2008, 9:17:06 PM10/12/08
to forma...@googlegroups.com
Issue 30: Key Error in AbstractField._validate [with patch]
http://code.google.com/p/formalchemy/issues/detail?id=30

Comment #1 by jbellis:
fixed radio bug in 517. thanks for the report!

validating a form submission against a differently-configured fieldset than
the one that initially created it is
expected to cause problems. don't do that. :)


Issue attribute updates:
Status: Fixed

Reply all
Reply to author
Forward
0 new messages