source: cows_wps/trunk/cows_wps/controllers/submit.py @ 5958

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/controllers/submit.py@5958
Revision 5958, 2.3 KB checked in by astephen, 11 years ago (diff)

more updates for submission form.

Line 
1import logging
2
3from pylons import request, response, session, tmpl_context as c
4from pylons.controllers.util import abort, redirect_to
5
6from cows_wps.renderer.ui_renderer import *
7from cows_wps.controllers import *
8from cows_wps.lib.ui.proc_config import *
9
10log = logging.getLogger(__name__)
11
12
13class SubmitController(BaseController):
14
15    def index(self):
16        """
17        Submits a job.
18        """
19        args = {}
20        for (key, value) in request.params.items():
21            args[str(key)] = str(value) 
22
23        proc_id = args["proc_id"]
24        del args["proc_id"]
25
26        wps_url_format = "/wps?Request=Execute&Format=text/xml&Identifier=%s&Store=false&Status=false&DataInputs="
27        wps_request = wps_url_format % proc_id
28
29        for (key, value) in args.items():
30            wps_request += "%s,%s," % (key, value)
31
32        # remove comma
33        wps_request = wps_request[:-1]
34
35        return redirect_to(wps_request) 
36
37    def choose(self):
38        """
39        Shows a drop-down list of possible procs to submit - to choose from.
40        """
41        pc = ProcConfig()
42        procs = pc.getProcList()
43
44        resp = """      <form action="/submit/form">
45                <p>Please select a process from the drop-down menu below and press 'GO' to generate a form to submit a job.</p>
46                <select name="proc_id">"""
47
48        for (proc, long_name) in procs.items():
49            resp += ('                  <option name="%s" value="%s">%s</option>\n' % (proc, proc, long_name))
50
51        resp += """             </select>
52                <input type="submit" value="GO" />
53        </form>"""
54
55        renderer = UIPageRenderer()
56        resp = renderer.render("Submission Form",
57                               [("Choose a process to submit a job to", resp)])
58
59        return resp
60
61
62    def form(self):
63        """
64        Displays a form for submitting a job.
65        """
66        proc = request.params.get("proc_id", None)
67        if proc == None:
68            return "Please provide an argument proc_id=&lt;Something&gt;"
69
70        pc = ProcConfig()
71        proc_submission_form_html = pc.renderProcSubmissionForm(proc)
72        resp = proc_submission_form_html
73
74        renderer = UIPageRenderer()
75        resp = renderer.render("Submission Form for: '%s'" % proc,
76                               [("Define your inputs", resp)])
77        return resp
78
Note: See TracBrowser for help on using the repository browser.