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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/controllers/test.py@7565
Revision 7565, 3.9 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
2
3from pylons import config
4
5from pylons import request, response, session, tmpl_context as c
6from pylons.controllers.util import abort, redirect_to
7from pylons.decorators import jsonify
8
9from beaker.middleware import SessionMiddleware
10
11from cows_wps.renderer.ui_renderer import *
12from cows_wps.controllers import *
13from cows_wps.lib.ui.proc_config import *
14from cows_wps.model.managers import requestManager
15from cows_wps.model.orm import tables
16
17#from cows_wps.utils.user_roles_dict import user_roles_config_dict
18from cows_wps.lib.user_manager import *
19
20log = logging.getLogger(__name__)
21
22
23class TestController(BaseController):
24
25    def index(self):
26        """
27        Shows a table of all procs.
28        """
29        try:
30            resp = str(user_roles_config_dict)
31        except Exception, err:
32            resp = str(err)
33
34               
35        return resp
36
37    @jsonify
38    def json(self):
39        return {"test": 1}
40
41    def qs(self):
42        import os
43        return str(request.environ.get("QUERY_STRING", "OHOHO"))
44
45    def show_config(self):
46        from cows_wps.utils.parse_capabilities_config import caps_config_dict
47        return str(caps_config_dict) 
48
49    def setcookie(self):
50        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)
51        return "I set it"
52
53       
54    def getcookie(self):
55        cookie_msg = request.cookies["wps_ui_error_msg"]
56        return "COOKIE: %s" % cookie_msg.replace("_", " ")
57
58    def beaker(self):
59        session = request.environ["beaker.session"]
60        resp = session
61#        resp = session._params
62        session["test1"] = "hi"
63       # session.save()
64        return str(resp)
65
66    def uu(self):
67        u = request.environ["REMOTE_USER"]
68        return u
69
70    def forward2(self):
71#        from paste.recursive import ForwardRequestException
72#        raise ForwardRequestException('/home.html')
73        result = request.environ['paste.recursive.include']('/test')
74        return str(result)
75
76    def sess(self):
77        resp = str(session)
78        return resp
79
80    def REQUEST_METHOD(self):
81        return request.environ.get("REQUEST_METHOD")
82
83    def userid(self):
84        um = UserManager()
85        return um.getUserName()
86
87    def email(self):
88        um = UserManager()
89        return um.getEmailAddress()
90
91    def abort(self):
92        """405 Method Not Allowed
93    A request was made of a resource using a request method not supported by that resource;[2] for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource."""
94        return abort(405)
95
96    def filterpost(self):
97        if self.REQUEST_METHOD() == "POST":
98            return abort(405)
99        else:
100            return "Good request"
101
102    def secured(self):
103        args = str(["%s;" % str(i) for i in request.params.items()[0]])
104        resp = "Request args received: %s" % args
105        return resp
106
107    def email2(self):
108        securitySession = request.environ.get('beaker.session.ndg.security')
109        openIdAxParams = securitySession["openid.ax"] 
110        resp = openIdAxParams["emailAddress"]
111        return resp
112
113    def cookies(self):
114        import cookielib
115        cj = cookielib.CookieJar() 
116        #return str(cj)
117        cookies = request.cookies.items()
118        resp = ""
119        for (k, v) in cookies:
120            resp += "<b>%s</b> = %s<br>" % (k, v)
121
122        import Cookie
123        k = Cookie.SimpleCookie()
124        k["ndg.security.session"] = "96bb6499953f3853bd4c36564fa6e266f239b11f232902baee883ece2ac5e73d91fdcbbb"
125
126        return resp
127
128    def dbtest(self):
129        sess = requestManager.getSession()
130        res = sess.query(tables.admin)[0]
131        admin_u = res.admin_name
132        admin_p = res.admin_password
133        return str(admin_u + "::" + admin_p)
Note: See TracBrowser for help on using the repository browser.