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

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

Tidied javascript.

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