Ignore:
Timestamp:
28/05/10 14:23:27 (10 years ago)
Author:
astephen
Message:

various updates. Key thing to add next is polling of jobs and update of
response when it has polled correctly. Can re-use jquery stuff in
submit_utils.js which is relatively lightweight.

File:
1 edited

Legend:

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

    r6898 r6903  
    4040        # If quick process then just forward 
    4141        if async == False: 
    42             base_url = "http://" + request.url[7:].split("/")[0] 
    43             full_url = base_url + wps_request_url 
    44             getter = urllib.urlopen(full_url) 
    45             xml = getter.read() 
    46             getter.close() 
    47             status_url = re.search('statusLocation="(.+?)"', xml).groups()[0] 
    48  
    49             jobviewer_url = url_for(controller='jobviewer', status_url = status_url)  
    50             return redirect_to(jobviewer_url) 
     42            return self._submitToWPSAndRedirectToJobViewer(wps_request_url) 
    5143 
    5244        # Now we are only dealing with async requests 
     45        cost_only_request_url = wps_request_url + "&Costonly=true" 
     46 
    5347        wps_resp_div = "wps_response_div" 
    54         resp = '<div>Submitting asynchronous request to get the cost of the request for: %s</div><div id="%s"></div>' % (proc_id, wps_resp_div) 
     48        resp = '<div>You have requested to run a "%s" job that will be run on the offline batch processing system. These jobs are controlled by a queuing system and it may take some time for your outputs to be produced.<br><br></div>' % proc_id 
     49 
     50        resp += '<div id="%s">Estimates of the size of the expected outputs and the duration of the job are being calculated...</div>' % wps_resp_div 
    5551        resp += """<script type="text/javascript"> 
    5652 
     
    5955        } 
    6056 
    61 </script>""" % (wps_request_url, wps_resp_div) 
     57</script>""" % (cost_only_request_url, wps_resp_div) 
     58 
     59        submitter_url = url_for(controller='submitter', action='conf') 
     60        resp += """<br><form id="confirmation" name="confirmation" action="%s" method="GET"> 
     61<input type="hidden" name="wps_request_url" value="%s" /> 
     62<input type="submit" name="submit" id="submit" value="Submit" disabled="disabled" /> 
     63</form>""" % (submitter_url, urllib.unquote(wps_request_url)) 
    6264 
    6365        renderer = UIPageRenderer() 
    64         resp = renderer.render("Submitting here", 
    65                                [("Submits or shows confirmation", resp)]) 
     66        resp = renderer.render("Confirmation page", 
     67                               [("Information about your asynchronous job", resp)]) 
    6668 
    6769        return resp 
     70 
     71 
     72    def _submitToWPSAndRedirectToJobViewer(self, wps_request_url): 
     73        "Submits request and gets statusLocation then redirects to job viewer controller." 
     74        base_url = "http://" + request.url[7:].split("/")[0] 
     75        full_url = base_url + wps_request_url 
     76 
     77        getter = urllib.urlopen(full_url) 
     78        xml = getter.read() 
     79        getter.close() 
     80 
     81        m = re.search('statusLocation="(.+?)"', xml) 
     82        status_url = m.groups()[0] 
     83 
     84        jobviewer_url = url_for(controller='jobviewer', status_url = status_url) 
     85        return redirect_to(jobviewer_url) 
     86 
     87 
     88    def conf(self): 
     89        "Called once confirmation is complete and just calls WPS and forwards." 
     90        wps_request_url = str(request.params.getone("wps_request_url")) 
     91        return self._submitToWPSAndRedirectToJobViewer(wps_request_url) 
     92         
    6893 
    6994    def _isAsync(self, proc_id): 
     
    7297        process_type = process_conf["wps_interface"]["process_type"] 
    7398 
    74         if process_type == "async_l": 
     99        if process_type.find("async") == 0: 
    75100            return True 
    76101        else: 
Note: See TracChangeset for help on using the changeset viewer.