Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed for success and failure callables

  • Loading branch information...
commit 56a6294170c24d2b7cb0521cc192080c34bdecfc 1 parent d735083
Tim Parkin authored
View
5 CHANGELOG
@@ -2,6 +2,11 @@
Changlelog
==========
+0.6.3 (2009-01-19)
+----------------
+
+BUG FIX: Success and Failure callbacks didn't work
+
0.6.2 (2009-01-19)
----------------
View
2  formish.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: formish
-Version: 0.6.2
+Version: 0.6.3
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
View
5 formish/forms.py
@@ -725,7 +725,7 @@ def validate(self, request, failure_callable=None, success_callable=None):
# first
if failure_callable is not None and success_callable is not None:
return self._validate_and_call(request, \
- failure_callable=None, success_callable=None)
+ failure_callable, success_callable)
self.errors = {}
# Check this request was POSTed by this form.
if not request.method =='POST' and \
@@ -759,8 +759,7 @@ def validate(self, request, failure_callable=None, success_callable=None):
raise validation.FormError(err_msg% (len(self.errors.keys())))
return data
- def _validate_and_call(self, request, \
- failure_callable=None, success_callable=None):
+ def _validate_and_call(self, request, failure_callable, success_callable):
try:
data = self.validate(request)
except validation.FormError, e:
View
22 formish/tests/unittests/test_core.py
@@ -156,6 +156,28 @@ def test_integer_type(self):
self.assertEqual( validation.convert_request_data_to_data(form.structure, dottedDict(request.POST)) , {'a': 3, 'b': '4'})
# Does the convert data to request work
self.assert_( validation.convert_data_to_request_data(form.structure, dottedDict( {'a': 3, 'b': '4'} )) == reqr)
+
+def success(request, data):
+ return 'success'
+
+def failure(request, form):
+ return 'failure'
+
+ def test_failure_and_success_callables(self):
+
+
+ schema_flat = schemaish.Structure([("a", schemaish.Integer(validator=validatish.Range(min=10))), ("b", schemaish.String())])
+ name = "Integer Form"
+ form = formish.Form(schema_flat, name)
+
+ r = {'a':'2','b': '4'}
+ request = Request(name, r)
+ self.assertEquals(form.validate(request, success, failure), 'failure')
+
+ r = {'a': '12', 'b': '4'}
+ request = Request(name, r)
+ form = formish.Form(schema_flat, name)
+ self.assertEquals(form.validate(request, success, failure), 'success')
def test_datetuple_type(self):
View
2  setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os, glob
-version = '0.6.2'
+version = '0.6.3'
setup(name='formish',
version=version,
Please sign in to comment.
Something went wrong with that request. Please try again.