summaryrefslogtreecommitdiffstats
path: root/funcweb
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-30 22:39:24 +0300
committermakkalot <makkalot@gmail.com>2008-06-30 22:39:24 +0300
commit48d76ba1e750d4a6f38cc720663637d3a7f6b3de (patch)
tree3aa725a2101a847db13f6fef840469ac72f6bc0c /funcweb
parent2dddee52d4bb4d06a4853fd33db13f6635ae1beb (diff)
downloadfunc-48d76ba1e750d4a6f38cc720663637d3a7f6b3de.tar.gz
func-48d76ba1e750d4a6f38cc720663637d3a7f6b3de.tar.xz
func-48d76ba1e750d4a6f38cc720663637d3a7f6b3de.zip
change the widget validation to handle the repeating fields
Diffstat (limited to 'funcweb')
-rw-r--r--funcweb/funcweb/widget_validation.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/funcweb/funcweb/widget_validation.py b/funcweb/funcweb/widget_validation.py
index 0347fa6..a7d61b7 100644
--- a/funcweb/funcweb/widget_validation.py
+++ b/funcweb/funcweb/widget_validation.py
@@ -266,6 +266,8 @@ class MinionListValidator(validators.FancyValidator):
"""
#will add more beautiful validation here after
#integrate the complex widgets for lists and dicts
+ #print "Im in the list validator the value i recieved is : ",value
+
if self.not_empty:
if len(value)==0:
raise validators.Invalid('Empty list passed when not_empty is set',value,state)
@@ -274,9 +276,13 @@ class MinionListValidator(validators.FancyValidator):
tmp = []
if type(tmp) != type(value):
value = list(value)
- value = [list_value.strip() for list_value in value]
-
- return value
+
+ #concert the data to proper format
+ final_list = []
+ for hash_data in value:
+ final_list.extend(hash_data.values())
+
+ return final_list
def validate_python(self,value,state):
import re
@@ -303,17 +309,26 @@ class MinionHashValidator(validators.FancyValidator):
"""
#will add more beautiful validation here after
#integrate the complex widgets for lists and dicts
+ print "Im in hash validator the value i recieved is ",value
+
if self.not_empty:
if len(value)==0:
raise validators.Invalid('Empty hash passed when not_empty is set',value,state)
+
+ #concert the data to proper format
+ final_hash = {}
+ for hash_data in value:
+ final_hash[hash_data['keyfield']] = hash_data['valuefield']
+
+
- #check the type firstly
+ #check the type firstly
tmp = {}
- if type(tmp) != type(value):
- raise validators.Invalid('The value passed to MinionHashValidator should be a dict object',value,state)
+ if type(tmp) != type(final_hash):
+ raise validators.Invalid('The value passed to MinionHashValidator should be a dict object',final_hash,state)
#print value
- return value
+ return final_hash
def validate_python(self,value,state):
#print value