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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changlelog 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) 0.6.4a (2009-01-22)
---------------- ----------------


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


version = '0.6.4a' version = '0.6.5'


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

0 comments on commit b51ef4b

Please sign in to comment.