source: cows_wps/trunk/cows_wps/controllers/submitter.py @ 6896

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/controllers/submitter.py@6896
Revision 6896, 2.0 KB checked in by astephen, 10 years ago (diff)

added and fixed stuff for new UI

Line 
1import os
2import glob
3import logging
4
5from pylons import request, response, session, tmpl_context as c
6from pylons.controllers.util import abort, redirect_to
7
8
9from cows.exceptions import *
10from cows.pylons.ows_controller import render_ows_exception
11
12from cows_wps.controllers import *
13from cows_wps import utils
14from cows_wps.renderer.ui_renderer import *
15from cows_wps.model.managers import requestManager
16from cows_wps.process_handler.context.process_context import ProcessContext
17from cows_wps.renderer import xml_renderer
18
19from cows_wps.utils.parse_wps_config import wps_config_dict
20from cows_wps.utils.parse_capabilities_config import caps_config_dict
21
22
23from cows_wps.model.managers import requestManager
24
25log = logging.getLogger(__name__)
26
27
28class SubmitterController(BaseController):
29
30
31    def index(self):
32        wps_request_url = str(request.params.getone("wps_request_url"))
33        proc_id = str(request.params.getone("proc_id"))
34
35        async = self._isAsync(proc_id)
36       
37        # If quick process then just forward
38        if async == False:
39            return redirect_to(wps_request_url)
40
41        # Now we are only dealing with async requests
42        wps_resp_div = "wps_response_div"
43        resp = '<div>Submitting asynchronous request to get the cost of the request for: %s</div><div id="%s"></div>' % (proc_id, wps_resp_div)
44        resp += """<script type="text/javascript">
45
46        function init() {
47                makeWPSRequest('%s', '%s');
48        }
49
50</script>""" % (wps_request_url, wps_resp_div)
51
52        renderer = UIPageRenderer()
53        resp = renderer.render("Submitting here",
54                               [("Submits or shows confirmation", resp)])
55
56        return resp
57
58    def _isAsync(self, proc_id):
59        "Returns boolean by looking up if WPS is async."
60        process_conf = caps_config_dict[proc_id]
61        process_type = process_conf["wps_interface"]["process_type"]
62
63        if process_type == "async_l":
64            return True
65        else:
66            return False
67       
Note: See TracBrowser for help on using the repository browser.