source: cows_wps/trunk/cows_wps/controllers/ajax_proxy.py @ 7565

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

Working on how the multiple dependencies on dynamic args will work.
Including WCSWrapper. Cross-domain security is still an issue.

Line 
1import logging
2import urllib
3
4from pylons import config
5
6from pylons import request, response, session, tmpl_context as c
7from pylons.controllers.util import abort, redirect_to
8from pylons.decorators import jsonify
9
10from cows.exceptions import *
11from cows_wps.controllers import *
12from cows_wps.model.managers import requestManager
13from cows_wps.utils.common import downloadFromURL, extractFromXML
14
15# Setup logger
16log = logging.getLogger(__name__)
17
18
19class AjaxProxyController(BaseController):
20
21    def index(self):
22        """
23        Shows a table of all procs.
24        """
25        try:
26            resp = str(user_roles_config_dict)
27        except Exception, err:
28            resp = str(err)
29
30               
31        return resp
32
33    @jsonify
34    def call_service(self):
35        # Check both args present
36        args = {}
37
38        for key in ("url", "xml_path"):
39            if not request.params.has_key(key):
40                raise OwsError("Must provide parameter: '%s'" % key)
41
42            args[key]= str(request.params.getone(key).strip())
43
44        unquoted_url = urllib.unquote(args["url"])
45#        log.warn("URL: %s" % unquoted_url)
46        xml = downloadFromURL(unquoted_url, cookies = request.cookies)
47        extracted_list = extractFromXML(xml, args["xml_path"])
48
49        QUERY_STRING = request.environ["QUERY_STRING"]
50        url_for_ui = "http://ceda-wps1.badc.rl.ac.uk/ajax_proxy/call_service?" + QUERY_STRING
51
52        resp = {"requested_url": url_for_ui,
53                "response": extracted_list}         
54#        response.content_type = 'text/xml'
55#        response.charset = 'utf-8'
56#        log.warn("%s" % str(xml))
57        return resp
58
59    def show_config(self):
60        from cows_wps.utils.parse_capabilities_config import caps_config_dict
61        return str(caps_config_dict) 
62
63    def setcookie(self):
64        response.set_cookie('wps_ui_error_msg', 'The WPS was run with the inputs you provided. The WPS rejected the job submission with the following error message. You may be able to modify your request to overcome this error.'.replace(" ", "_"), expires=3600)
65        return "I set it"
66
67       
68    def getcookie(self):
69        cookie_msg = request.cookies["wps_ui_error_msg"]
70        return "COOKIE: %s" % cookie_msg.replace("_", " ")
Note: See TracBrowser for help on using the repository browser.