Changeset 7000 for cows_wps


Ignore:
Timestamp:
13/06/10 20:18:30 (9 years ago)
Author:
astephen
Message:

various fixes on bbox etc

Location:
cows_wps/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/cows_wps/controllers/jobviewer.py

    r6976 r7000  
    131131            if item == "JobCapabilities" and x.find("send_to_extract_weather_data") > -1: 
    132132                x = x.replace("send_to_extract_weather_data",  
    133                   '<a href="/submit/form?proc_id=ExtractUKStationData&StationsFileURL=%s">Use stations to extract UK weather data</a>' % file_set_list[0].find("{" + self.namespace +  "}FileURL").text) 
     133                  '<a href="/submit/form?proc_id=ExtractUKStationData&StationsFile=%s">Use stations to extract UK weather data</a>' % file_set_list[0].find("{" + self.namespace +  "}FileURL").text) 
    134134  
    135135            resp += "<b>%s</b> = %s<br>" % (mapped_names[i], x.strip()) 
  • cows_wps/trunk/cows_wps/controllers/submitter.py

    r6955 r7000  
    44import logging 
    55import urllib 
    6 import urllib2 
    7 import Cookie 
    8 import datetime 
    96 
    107from pylons import request, response, session, tmpl_context as c 
     
    1714 
    1815from cows_wps.controllers import * 
    19 from cows_wps import utils 
    2016from cows_wps.renderer.ui_renderer import * 
    2117from cows_wps.model.managers import requestManager 
     
    2521from cows_wps.utils.parse_wps_config import wps_config_dict 
    2622from cows_wps.utils.parse_capabilities_config import caps_config_dict 
     23from cows_wps.utils.common import downloadFromURL 
    2724 
    2825 
     
    7875        clean_request_url = base_url + urllib.unquote(wps_request_url) 
    7976 
     77        """ 
    8078        req = urllib2.Request(url = clean_request_url) 
    8179        cookies = request.cookies 
     
    9795        xml = getter.read() 
    9896        getter.close() 
     97        """ 
     98 
     99        xml = downloadFromURL(clean_request_url, cookies = request.cookies) 
    99100 
    100101        m = re.search('statusLocation="(.+?)"', xml) 
  • cows_wps/trunk/cows_wps/controllers/test.py

    r6949 r7000  
    55from pylons import request, response, session, tmpl_context as c 
    66from pylons.controllers.util import abort, redirect_to 
     7 
     8from beaker.middleware import SessionMiddleware 
    79 
    810from cows_wps.renderer.ui_renderer import * 
     
    3032                 
    3133        return resp 
     34 
     35    def beaker(self): 
     36        session = request.environ["beaker.session"] 
     37        resp = session 
     38#        resp = session._params  
     39        session["test1"] = "hi" 
     40       # session.save() 
     41        return str(resp) 
    3242 
    3343    def forward2(self): 
  • cows_wps/trunk/cows_wps/lib/ui/proc_config.py

    r6976 r7000  
    192192            elif tp in ("float", "int", "string", "datetime"): 
    193193                if tp == "datetime": 
    194                     if default: 
     194                    if args.has_key(name): 
     195                        # Use input arg sent in to form if received 
     196                        default = args[name] 
     197                    elif default: 
    195198                        # Ensure time formatted correctly 
    196199                        default = str(default).replace(" ", "T") 
     
    198201                    instruction += " Please insert a date/time field in the format <kbd><B>YYYY-MM-DDThh:mm:ss</B></kbd> such as <kbd>2009-01-01T00:00:00</kbd>." 
    199202                else: 
     203                    # Use CGI arg if received 
    200204                    if args.has_key(name): 
    201205                        default = args[name] 
  • cows_wps/trunk/cows_wps/public/js/ui/validate.js

    r6977 r7000  
    88// Define validation globals 
    99var invalid_input_msg = "You have submitted an invalid input, please try again. "; 
    10  
    11 /* function: validate(): 
    12    Inputs: 
    13      * full name of option 
    14      * value  
    15      * data_type 
    16      * multiple allowed = true || false 
    17      * possible_values = array OR false 
    18      * allowed length - relevant to arrays 
    19 */ 
    20 function OLDOLDvalidate(name, value, data_type, multiple, possible_values, allowed_length) { 
    21 } 
    2210 
    2311/*  
     
    146134        // which represents (west|east|south|north) 
    147135        // Checks domain is within spec_arg domain 
     136        return true; 
    148137        var selected_bbox = parseBBoxString(input); 
    149138        var valid_bbox = parseBBoxString(valid_bbox); 
     
    159148var validators = new Array(); 
    160149/* Validator is a pseudo-class */ 
    161 function Validator(name, validation_type, regex_match, msg, optional) { 
     150function Validator(name, validation_type, spec_arg, msg, optional) { 
    162151    this.name = name; 
    163152    this.validation_type = validation_type; 
    164     this.regex_match = regex_match; 
     153    this.spec_arg = spec_arg; 
    165154    this.msg = msg; 
    166155    this.optional = optional; 
     
    193182    * optional - boolean to say that arg is optional or not 
    194183*/ 
    195 function addValidator(name, validation_type, regex_match, msg, optional) { 
    196     var vdr = new Validator(name, validation_type, regex_match, msg, optional); 
     184function addValidator(name, validation_type, spec_arg, msg, optional) { 
     185    var vdr = new Validator(name, validation_type, spec_arg, msg, optional); 
    197186    var this_arr = new Array(vdr); 
    198187    validators = validators.concat(this_arr); 
     
    212201        var validation_type = vdr.validation_type; 
    213202         
    214                 // spec_arg can be a regex_match or any other object you want the validator to work with 
     203        // spec_arg can be a regex_match or any other object you want the validator to work with 
    215204        var spec_arg = vdr.spec_arg; 
    216205        var msg = vdr.msg;  
  • cows_wps/trunk/cows_wps/renderer/form_renderer.py

    r6977 r7000  
    9999        return html 
    100100 
    101     def OLDrenderBBox(self, name, extent="90|-180|-90|180"): 
    102         """ 
    103         Renders a bounding box and N/W/S/E/ selectors. 
    104         """ 
    105         if extent == False: extent = "90|-180|-90|180" 
    106  
    107         (n, w, s, e) = extent.split("|") 
    108  
    109         html = """      <label for="_north">North:</label> <input type="text" id="_north" name="_north" value="%s" onChange="updateBBox('%s');" /><br> 
    110         <label for="_west">West:</label> <input type="text" id="_west" name="_west" value="%s" onChange="updateBBox('%s');" /><br> 
    111         <label for="_south">South:</label> <input type="text" id="_south" name="_south" value="%s" onChange="updateBBox('%s');" /><br> 
    112         <label for="_east">East:</label> <input type="text" id="_east" name="_east" value="%s" onChange="updateBBox('%s');" /><br> 
    113         <input type="hidden" id="%s" name="%s" value="%s" /> 
    114         """ % (n, name, w, name, s, name, e, name, name, name, extent) 
    115  
    116         return html 
    117  
    118101 
    119102    def renderBBox(self, name, extent): 
    120103        """ 
    121104        Renders a bounding box and N/W/S/E selectors. 
    122         ``extent`` is received as a string of "north|west|south|east". 
     105        ``extent`` is received as a string of "west|south|east|north". 
    123106        """ 
    124107        if extent == False: extent = "90|-180|-90|180" 
     
    134117            <script type="text/javascript"> 
    135118                var initial_extent = [%s, %s, %s, %s]; 
    136                 addValidator('%s', 'bounding_box', extent, 'Your selected spatial bounding box must overlap with the available extent of: (%s) as ("north|west|south|east").', false); 
     119                addValidator('bbox_hidden_input', 'bounding_box', '%s', 'Your selected spatial bounding box must overlap with the available extent of: (%s) as ("north|west|south|east").', false); 
    137120            </script> 
    138121        </div> 
    139         """ % (name, n, w, s, e, name, extent) 
     122        """ % (name, n, w, s, e, extent, extent) 
    140123 
    141124        return html      
  • cows_wps/trunk/cows_wps/utils/common.py

    r6899 r7000  
    1515import string 
    1616import datetime 
     17import urllib2 
     18import Cookie 
    1719 
    1820from cows_wps.utils import case_sensitive_ordered_config_parser as cp 
     
    247249 
    248250 
     251def downloadFromURL(url, cookies = None): 
     252    """ 
     253    Downloads response from URL. Use cookies if ``cookies`` is defined. 
     254    """ 
     255    req = urllib2.Request(url = url) 
     256 
     257    # Now go through each cookie and add it to the request object before sending 
     258    if cookies != None: 
     259        for cookie in cookies.items(): 
     260            new_cookie = Cookie.SimpleCookie() 
     261            (k, v) = cookie 
     262            new_cookie[k] = v 
     263            new_cookie[k]["path"] = "/" 
     264            req.add_header('Cookie', new_cookie.output()) 
     265 
     266    getter = urllib2.urlopen(req) 
     267    resp = getter.read() 
     268    getter.close() 
     269    return resp 
     270 
     271def mapDownloadURLToFilePath(url): 
     272    items = url.split("/") 
     273    (job_id, file_name) = items[-2:] 
     274    req = requestManager.getRequest(jobId, sgeUpdate=False) 
     275    processDir = req.job.process_dir 
     276#    identifier = req.job.process 
     277 
     278 
     279 
    249280if __name__ == "__main__": 
    250281 
Note: See TracChangeset for help on using the changeset viewer.