Skip to content

Commit

Permalink
fixed bug in choice widgets that raised error when bad request data w…
Browse files Browse the repository at this point in the history
…as given
  • Loading branch information
Tim Parkin committed Jan 23, 2009
1 parent 673af6f commit b51ef4b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,11 @@
Changlelog
==========

0.6.5 (2009-01-23)
----------------

BUG FIX: convert error if a choice type is given bad request data.

0.6.4a (2009-01-22)
----------------

Expand Down
2 changes: 1 addition & 1 deletion formish.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: formish
Version: 0.6.4a
Version: 0.6.5
Summary: Formish is a schema backed, templating language agnostic form generation and handling library.
Home-page: http://ish.io/projects/show/formish
Author: Tim Parkin, Matt Goodall
Expand Down
24 changes: 19 additions & 5 deletions formish/widgets.py
Expand Up @@ -395,7 +395,11 @@ def selected(self, option, value, schema_type):
v = self.empty
else:
v = value
if option[0] == self.convert(schema_type, [v]):
try:
cv = string_converter(schema_type).to_type(v)
except ConvertError:
return ''
if option[0] == cv:
return ' selected="selected"'
else:
return ''
Expand Down Expand Up @@ -526,7 +530,11 @@ def selected(self, option, value, schema_type):
v = self.empty
else:
v = value
if option[0] == self.convert(schema_type, [v]):
try:
cv = string_converter(schema_type).to_type(v)
except ConvertError:
return ''
if option[0] == cv:
return ' checked="checked"'
else:
return ''
Expand Down Expand Up @@ -570,9 +578,15 @@ def checked(self, option, values, schema_type):
"""
For each value, convert it and check to see if it matches the input data
"""
if values is not None:
typed_values = self.convert(schema_type, values)
if values is not None and option[0] in typed_values:
if values is None:
return ''
cvs = []
for v in values:
try:
cvs.append( string_converter(schema_type.attr).to_type(v) )
except ConvertError:
continue
if option[0] in cvs:
return ' checked="checked"'
else:
return ''
Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os, glob

version = '0.6.4a'
version = '0.6.5'

setup(name='formish',
version=version,
Expand Down

0 comments on commit b51ef4b

Please sign in to comment.