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

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

getting status monitoring working properly.

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