summaryrefslogtreecommitdiffstats
path: root/funcweb
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-21 11:40:19 +0300
committermakkalot <makkalot@gmail.com>2008-06-21 11:40:19 +0300
commit056714c8566d028ccab6d217a615d9a14e185b58 (patch)
treed2e7b5e9d3d5fe42a6754fe395243b2cc87d83f0 /funcweb
parent9563511c6d4dbda5a9e2ec053f0765bcc21f5e6f (diff)
downloadthird_party-func-056714c8566d028ccab6d217a615d9a14e185b58.tar.gz
third_party-func-056714c8566d028ccab6d217a615d9a14e185b58.tar.xz
third_party-func-056714c8566d028ccab6d217a615d9a14e185b58.zip
forgot to add optional keyword into validation controls :)
Diffstat (limited to 'funcweb')
-rw-r--r--funcweb/funcweb/tests/test_widget_validation.py10
-rw-r--r--funcweb/funcweb/widget_validation.py15
2 files changed, 25 insertions, 0 deletions
diff --git a/funcweb/funcweb/tests/test_widget_validation.py b/funcweb/funcweb/tests/test_widget_validation.py
index 94a3d1e..e501b53 100644
--- a/funcweb/funcweb/tests/test_widget_validation.py
+++ b/funcweb/funcweb/tests/test_widget_validation.py
@@ -58,6 +58,11 @@ class TestWidgetValidator(unittest.TestCase):
if arg_options.has_key('max'):
#print " ",argument_name," : ",getattr(schema_man,argument_name)
assert getattr(getattr(schema_man,argument_name),'max') == arg_options['max']
+
+ if arg_options.has_key('optional'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert not getattr(getattr(schema_man,argument_name),'not_empty') == arg_options['optional']
+
print "Happy test!"
@@ -78,6 +83,11 @@ class TestWidgetValidator(unittest.TestCase):
#print " ",argument_name," : ",getattr(schema_man,argument_name)
assert getattr(getattr(schema_man,argument_name),'max') == arg_options['max']
+ if arg_options.has_key('optional'):
+ #print " ",argument_name," : ",getattr(schema_man,argument_name)
+ assert not getattr(getattr(schema_man,argument_name),'not_empty') == arg_options['optional']
+
+
print "Happy test!"
diff --git a/funcweb/funcweb/widget_validation.py b/funcweb/funcweb/widget_validation.py
index 230c501..0f908a8 100644
--- a/funcweb/funcweb/widget_validation.py
+++ b/funcweb/funcweb/widget_validation.py
@@ -37,6 +37,13 @@ class WidgetSchemaFactory(object):
#the initializer for the int_validator
int_data_set = {}
+ #the optional keyword
+ if self.method_argument_dict[argument_name].has_key('optional'):
+ if self.method_argument_dict[argument_name]['optional']:
+ int_data_set['not_empty']=False
+ else:
+ int_data_set['not_empty']=True
+
if self.method_argument_dict[argument_name].has_key('range'):
#because the range is [min,max] list the 0 is min 1 is the max
int_data_set['min']=self.method_argument_dict[argument_name]['range'][0]
@@ -101,6 +108,14 @@ class WidgetSchemaFactory(object):
#the initializer for the float_validator
float_data_set = {}
+ #is it optional
+ if self.method_argument_dict[argument_name].has_key('optional'):
+ if self.method_argument_dict[argument_name]['optional']:
+ float_data_set['not_empty']=False
+ else:
+ float_data_set['not_empty']=True
+
+
if self.method_argument_dict[argument_name].has_key('min'):
float_data_set['min']=self.method_argument_dict[argument_name]['min']
if self.method_argument_dict[argument_name].has_key('max'):