Changeset 6111
- Timestamp:
- 11/12/09 21:03:17 (11 years ago)
- Location:
- cows_wps/trunk/cows_wps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cows_wps/trunk/cows_wps/process_handler/validate_arguments.py
r5994 r6111 16 16 import sys 17 17 import re 18 import dateutil.parser 19 import datetime 18 20 19 21 import logging … … 41 43 if dtype in ("xml", "filepath"): 42 44 dtype = "string" 45 elif dtype == "datetime": 46 return parseDateTime(item) 47 elif dtype in ("bbox",): 48 dtype = "float" 43 49 44 50 transformer = dtype … … 129 135 130 136 return array 137 138 139 def parseDateTime(item): 140 """ 141 Checks that item is a valid date time string: 'YYYY-MM-DDThh:mm:ss'. 142 """ 143 pattn = re.compile("^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$") 144 if not pattn.match(item): 145 raise Exception("Item does not match date/time pattern.") 146 147 date_time_value = dateutil.parser.parse("2008-02-23T12:12:12") 148 return date_time_value 131 149 132 150 … … 161 179 log.debug("Validating list of arguments:(%s)" % (self.args,)) 162 180 163 # log.debug("NOTE: policy of this code is to ignore any unknown arguments but not to raise an exception") 181 # NOTE:policy of this code is to ignore any unknown arguments but not to raise an exception 164 182 for name in arg_names: 165 # log.debug('Validating argument %s' % name) 183 166 184 try: 167 185 # define d as the entry for this particular argument … … 171 189 if name not in self.args.keys(): 172 190 log.debug ("DataInput %s not present in args" % (name,)) 173 #check if it is optional or has a default value 174 191 192 # Check if it is optional or has a default value 175 193 if d.has_key("default"): 176 194 value = d["default"] … … 192 210 193 211 new_dict[name] = parseValue(value_given, d) 194 # log.debug("Using value of %s for %s" % (new_dict[name], name))195 212 196 213 except: … … 205 222 % (recievedParam, self.process_name)) 206 223 207 # log.debug("VALID DICT: %s" % new_dict)208 224 return new_dict 209 225 -
cows_wps/trunk/cows_wps/renderer/form_renderer.py
r5994 r6111 37 37 Returns HTML for text input including onChange validator. 38 38 """ 39 allowed_dtypes = ("float", "int", "string") 39 allowed_dtypes = ("float", "int", "string", "datetime") 40 40 41 if dtype not in allowed_dtypes: 41 42 raise Exception("Invalid type sent to FormRenderer.renderTextInput(): %s" % dtype) … … 43 44 validators = {"int": ("/^[0-9]+$/", "The %s input must be an integer." % name), 44 45 "float": ("/^[-+]?([0-9]*\.[0-9]+|[0-9]+)$/", "The %s input must be a decimal number." % name), 45 "string": ("/[0-9a-zA-Z]+/", "The %s input must include text characters." % name)} 46 "string": ("/[0-9a-zA-Z]+/", "The %s input must include text characters." % name), 47 "datetime": ("/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}/", "The %s input must be a date/time entry as follows YYYY-MM-DDThh:mm:ss (e.g. 2009-01-01T12:00:00)." % name)} 46 48 47 49 (regex, msg) = validators[dtype] … … 61 63 62 64 return html 65 66 def renderBBox(self, name, extent): 67 """ 68 Renders a bounding box and N/W/S/E selectors. 69 """ 70 html = """ <script type="text/javascript" src="/js/ext/jquery-1.3.2/jquery-1.3.2.js"></script> 71 <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script> 72 <script type="text/javascript" src="/js/ui/openlayers-x.js"></script> 73 <script type="text/javascript" src="/js/ui/boundingBoxMapSelect.js"></script> 74 <script type="text/javascript"> 75 var layers = new Array(); 76 var layer_data = false; 77 var bboxSelect = false; 78 79 $(document).ready(function() { 80 var layer_data = new OpenLayers.Layer.WMS( "World Map", "http://labs.metacarta.com/wms-c/Basic.py?", {layers: 'basic', format: 'image/png' } ); 81 layers.push(layer_data); 82 var bboxSelect = new BoundingBoxMapSelect('map', 'bounds_control_container', layers, 'bbox_hidden_input', null); 83 }); 84 </script> 85 86 <div id="bounding_container"> 87 <div id="bounds_control_container"></div> 88 <div id="map_container"> 89 <div id='map'></div> 90 </div> 91 <input type="hidden" name="bbox" id="bbox_hidden_input" value="" /> 92 </div> 93 """ 94 return html 63 95 64 96 def renderTypeAheadDirList(self, name, base_dir): -
cows_wps/trunk/cows_wps/utils/parse_capabilities_config.py
r5994 r6111 16 16 Keywords "default:<default_value>" AND/OR "optional" None, one or both, comma-separated. For neither just use "-" 17 17 Enumerated Values <s1>,<s2>,<s3> Comma-separated list of values that all entries must be one of. Use "-" for none. 18 Base directory applies to filepath type which is a string that should be a filepath19 18 """ 20 19 … … 66 65 outin_dict = {} 67 66 68 allowed_types = ("xml", 'complex','xml_complex_value',"string", "float", "int", "bool", "filepath" )67 allowed_types = ("xml", 'complex','xml_complex_value',"string", "float", "int", "bool", "filepath", "bbox", "datetime") 69 68 70 69 for item in outputInputDict: … … 129 128 if outputInputDict.has_key(param + ".basedir"): 130 129 item_dict["basedir"] = outputInputDict[param+ ".basedir"].strip() 130 131 if outputInputDict.has_key(param + ".extent"): 132 item_dict["extent"] = outputInputDict[param + ".extent"].strip() 131 133 132 134 outin_dict[param.strip()] = item_dict
Note: See TracChangeset
for help on using the changeset viewer.