Permalink
Browse files

made sure the empty attribute worked symettrically (goes with removin…

…g empty string checking from convertish)
  • Loading branch information...
1 parent 795aa06 commit dd868936628c9728d9fedf762184e0b0648063be Tim Parkin committed Jan 22, 2009
View
37 CHANGELOG
@@ -2,6 +2,16 @@
Changlelog
==========
+0.6.4 (2009-01-22)
+----------------
+
+ * Added object base class to enable 2.4 comptibility
+
+BUG FIX: made sure the 'empty' attribute worked symettrically (goes with
+ removing empty string checking from convertish)
+BUG FIX: none_option default was empty string which broke when using datetype.
+BUG FIX: sequences could not be used as values in select choice
+
0.6.3 (2009-01-19)
----------------
@@ -10,15 +20,18 @@ BUG FIX: Success and Failure callbacks didn't work
0.6.2 (2009-01-19)
----------------
-* Added testish tests for default values using radio choice and check box as booleans
+* Added testish tests for default values using radio choice and check box as
+ booleans
BUG FIX: Radio choice type conversion was broken
0.6.1 (2009-01-17)
----------------
-* Added the 'empty' attribute to allow empty values to come back as anything you like (normally they return None)
-* Reviewed the way conversion works and added extra tests.. picked up on a couple of edge cases
+* Added the 'empty' attribute to allow empty values to come back as anything
+ you like (normally they return None)
+* Reviewed the way conversion works and added extra tests.. picked up on a
+ couple of edge cases
BUG FIX: bugs in the conversion of none_option values
@@ -29,7 +42,8 @@ BUG FIX: bugs in the conversion of none_option values
Hopefully we're over the backward incompatible api changes.
* added ``sortable`` option to sequence widget
-* renamed the default form id back to 'form' (it temporarily got set as 'formish'). js and css might need changing in your projects..
+* renamed the default form id back to 'form' (it temporarily got set as
+ 'formish'). js and css might need changing in your projects..
* Added ReCAPTCHA widget and enhanced the testish self documenting site
* big introduction page to docs
@@ -43,32 +57,37 @@ BUG FIX: resizing when only with or height given was not working
0.5.8 (2009-01-12)
------------------
-* added a SelectWithOther choice and enhanced unit and func test capabilities in testish
+* added a SelectWithOther choice and enhanced unit and func test capabilities
+ in testish
0.5.7 (2009-01-11)
------------------
BUG FIX: Fixed various problems with File uploads.
-* added a default file acccessor that uses python tempfile with a 'store-' file prefix.
+* added a default file acccessor that uses python tempfile with a 'store-' file
+ prefix.
0.5.6 (2009-01-09)
------------------
-BUG FIX: Fixed bug when using multi part widgets (e.g. Date Parts) inside a sequence. Added example test case.
+BUG FIX: Fixed bug when using multi part widgets (e.g. Date Parts) inside a
+ sequence. Added example test case.
* changes to handle new schemaish Invalid exception format
* added a contains-error class to container classes that do.
0.5.5 (2009-01-08)
------------------
-Add a granular template rendering system (have a look at http://ish.io:8891/CustomisedFormLayout)
+* Add a granular template rendering system (have a look at
+ http://ish.io:8891/CustomisedFormLayout)
0.5.4 (2009-01-06)
------------------
-Removed all * imports apart from those at the module level. Checked against pyflakes.
+* Removed all * imports apart from those at the module level. Checked against
+ pyflakes.
0.5.3 (2009-01-06)
------------------
View
4 formish.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: formish
-Version: 0.6.3
+Version: 0.6.4
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
@@ -12,7 +12,7 @@ Description: Formish is a schema backed, templating language agnostic form gener
-Keywords: form,forms,widgets,form library,
+Keywords: form forms widgets form library
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
View
2 formish.egg-info/SOURCES.txt
@@ -24,6 +24,7 @@ docs-build/index.rst
docs-build/introduction.rst
docs-build/modules.rst
docs-build/restish.rst
+docs-build/run
docs-build/walkthrough.rst
docs-build/.build/doctrees/environment.pickle
docs-build/.build/doctrees/index.doctree
@@ -286,6 +287,7 @@ formish/templates/mako/formish/widgets/Hidden/widget.html
formish/templates/mako/formish/widgets/Input/widget.html
formish/templates/mako/formish/widgets/Password/widget.html
formish/templates/mako/formish/widgets/RadioChoice/widget.html
+formish/templates/mako/formish/widgets/SelectChoice/sequence.html
formish/templates/mako/formish/widgets/SelectChoice/widget.html
formish/templates/mako/formish/widgets/SelectWithOtherChoice/widget.html
formish/templates/mako/formish/widgets/TextArea/sequence.html
View
4 formish.egg-info/requires.txt
@@ -1,6 +1,6 @@
PEAK-Rules >= 0.5a1.dev_r2582
ProxyTypes >= 0.9
schemaish >= 0.5.2
-validatish >= 0.5.1
-convertish >= 0.5.2
+validatish >= 0.5.4
+convertish >= 0.5.3
webob >= 0.9.5
View
7 formish/tests/testish/functest
@@ -2,14 +2,9 @@
case "$1" in
one)
./run nosetests testish/lib/test_func.py:TestSeparately.test_$2
- --daemon \
- --pid-file=$GITDIR/formish/formish/tests/testish/log/live.pid \
- --log-file=$GITDIR/formish/formish/tests/testish/log/live.log \
- $GITDIR/formish/formish/tests/testish/live.ini \
- start
;;
*)
- ./run nosetests testish/lib/test_func.py:TestTogether
+ ./run nosetests testish/lib/test_func.py:TestTogether
;;
esac
View
27 formish/tests/testish/testish/lib/forms.py
@@ -134,13 +134,13 @@ def functest_Integer(self):
sel.type("form-myIntegerField", "a")
sel.click("form-action-submit")
sel.wait_for_page_to_load("30000")
- try: self.failUnless(sel.is_text_present("Not a valid number"))
+ try: self.failUnless(sel.is_text_present("Not a valid integer"))
except AssertionError, e: self.verificationErrors.append(str(e))
sel.type("form-myIntegerField", "8.0")
sel.click("form-action-submit")
sel.wait_for_page_to_load("30000")
- try: self.failUnless(sel.is_text_present("Not a valid number"))
+ try: self.failUnless(sel.is_text_present("Not a valid integer"))
except AssertionError, e: self.verificationErrors.append(str(e))
sel.type("form-myIntegerField", "8")
@@ -632,12 +632,25 @@ def form_OneOf(request):
def form_All(request):
"""
- Required and Plain Text (alphanum only plus _ and -)
+ Required, Integer and Value >= 18
"""
schema = schemaish.Structure()
- schema.add('requiredPlainText',
- schemaish.String(validator=validatish.All(
- validatish.Required(),validatish.PlainText(extra='-_')
+ schema.add('minAge',
+ schemaish.Integer(validator=validatish.All(
+ validatish.Required(), validatish.Integer(), validatish.Range(min=18)
+ )))
+
+ form = formish.Form(schema, 'form')
+ return form
+
+def form_Any(request):
+ """
+ Any of the validators passing will mean a pass - implements 'no teenagers please'
+ """
+ schema = schemaish.Structure()
+ schema.add('noTeenagers',
+ schemaish.Integer(validator=validatish.Any(
+ validatish.Range(max=12), validatish.Range(min=20),
)))
form = formish.Form(schema, 'form')
@@ -874,7 +887,7 @@ def functest_SelectWithOtherChoice(self):
sel.type("form-mySelect-other", "d")
sel.click("form-action-submit")
sel.wait_for_page_to_load("30000")
- try: self.failUnless(sel.is_text_present("Not a valid number"))
+ try: self.failUnless(sel.is_text_present("Not a valid integer"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.assertEqual("...", sel.get_value("form-mySelect"))
View
2 formish/tests/testish/testish/templates/root.html
@@ -45,7 +45,7 @@
<h3>Validation Examples</h3>
<%
-ids = ['Required', 'MinLength','MaxLength','MinMaxLength','MinLengthCheckboxMultiChoice','MinRange','MaxRange','MinMaxRange','PlainText','OneOf','All','ReCAPTCHA','ValidationOnSequenceItem','ValidationOnSequence','RequiredStringAndFile']
+ids = ['Required', 'MinLength','MaxLength','MinMaxLength','MinLengthCheckboxMultiChoice','MinRange','MaxRange','MinMaxRange','PlainText','OneOf','All','Any','ReCAPTCHA','ValidationOnSequenceItem','ValidationOnSequence','RequiredStringAndFile']
links(ids)
%>
View
63 formish/widgets.py
@@ -391,7 +391,11 @@ def selected(self, option, value, schema_type):
"""
Check the value passed matches the actual value
"""
- if value and option[0] == self.convert(schema_type, [value]):
+ if value == '':
+ v = self.empty
+ else:
+ v = value
+ if option[0] == self.convert(schema_type, [v]):
return ' selected="selected"'
else:
return ''
@@ -402,17 +406,20 @@ def get_options(self, schema_type):
"""
options = []
for value, label in self.options:
- options.append(
- (string_converter(schema_type).from_type(value),label)
- )
+ if value == self.empty:
+ options.append( ('',label) )
+ else:
+ options.append( (string_converter(schema_type).from_type(value),label) )
return options
def get_none_option_value(self, schema_type):
"""
Get the default option (the 'unselected' option)
"""
- return string_converter(schema_type).from_type(
- self.none_option[0])
+ none_option = string_converter(schema_type).from_type(self.none_option[0])
+ if none_option is self.empty:
+ return ''
+ return none_option
class SelectWithOtherChoice(SelectChoice):
"""
@@ -457,21 +464,28 @@ def convert(self, schema_type, request_data):
return string_converter(schema_type).to_type(value)
def get_other_option(self, schema_type):
- """
- Get the other option
- """
- return (string_converter(schema_type).from_type(
- self.other_option[0]), self.other_option[1])
+ """ Get the other option """
+ return (string_converter(schema_type).from_type( self.other_option[0]), self.other_option[1] )
def selected(self, option, value, schema_type):
- """
- Check the value passed matches the actual value
- """
- if option[0] == '...' and value not in [value for value, label in self.options]:
+ """ Check the value passed matches the actual value """
+ if option[0] == '...' and value not in [value for value, label in self.get_options(schema_type)]:
return ' selected="selected"'
- if option[0] == value:
+ # Map the empty value
+ if value == '':
+ v = self.empty
+ else:
+ v = value
+ # Convert or raise
+ try:
+ cv = string_converter(schema_type).to_type(v)
+ except ConvertError:
+ return ''
+ # Check for selected
+ if option[0] == cv
return ' selected="selected"'
- return ''
+ else:
+ return ''
class RadioChoice(Widget):
"""
@@ -480,7 +494,7 @@ class RadioChoice(Widget):
_template = 'RadioChoice'
- none_option = ('', '- choose -')
+ none_option = (None, '- choose -')
def __init__(self, options, **k):
none_option = k.pop('none_option', UNSET)
@@ -508,7 +522,11 @@ def selected(self, option, value, schema_type):
"""
Check if the currently rendering input is the same as the value
"""
- if value and option[0] == self.convert(schema_type, [value]):
+ if value == '':
+ v = self.empty
+ else:
+ v = value
+ if option[0] == self.convert(schema_type, [v]):
return ' checked="checked"'
else:
return ''
@@ -517,9 +535,10 @@ def get_none_option_value(self, schema_type):
"""
Get the default option (the 'unselected' option)
"""
- none_val = string_converter(schema_type).from_type(
- self.none_option[0])
- return none_val
+ none_option = string_converter(schema_type).from_type(self.none_option[0])
+ if none_option is self.empty:
+ return ''
+ return none_option
class CheckboxMultiChoice(Widget):
"""
View
6 setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os, glob
-version = '0.6.3'
+version = '0.6.4'
setup(name='formish',
version=version,
@@ -38,8 +38,8 @@
'PEAK-Rules >= 0.5a1.dev_r2582',
'ProxyTypes >= 0.9',
'schemaish >= 0.5.2',
- 'validatish >= 0.5.1',
- 'convertish >= 0.5.2',
+ 'validatish >= 0.5.4',
+ 'convertish >= 0.5.3',
'webob >= 0.9.5',
],
entry_points="""

0 comments on commit dd86893

Please sign in to comment.