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

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

various fixes to get user picked up and cookies working.

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 cows_wps.renderer.ui_renderer import *
9from cows_wps.controllers import *
10from cows_wps.lib.ui.proc_config import *
11
12from cows_wps.utils.user_roles_dict import user_roles_config_dict
13from cows_wps.lib.user_manager import *
14
15
16log = logging.getLogger(__name__)
17
18
19class TestController(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    def forward2(self):
34#        from paste.recursive import ForwardRequestException
35#        raise ForwardRequestException('/home.html')
36        result = request.environ['paste.recursive.include']('/test')
37        return str(result)
38
39    def sess(self):
40        resp = str(session)
41        return resp
42
43    def REQUEST_METHOD(self):
44        return request.environ.get("REQUEST_METHOD")
45
46    def userid(self):
47        um = UserManager()
48        return um.getUserName()
49
50    def email(self):
51        um = UserManager()
52        return um.getEmailAddress()
53
54    def abort(self):
55        """405 Method Not Allowed
56    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."""
57        return abort(405)
58
59    def filterpost(self):
60        if self.REQUEST_METHOD() == "POST":
61            return abort(405)
62        else:
63            return "Good request"
64
65    def secured(self):
66        return "Did you get asked for security info?"
67
68    def email2(self):
69        securitySession = request.environ.get('beaker.session.ndg.security')
70        openIdAxParams = securitySession["openid.ax"] 
71        resp = openIdAxParams["emailAddress"]
72        return resp
73
74    def cookies(self):
75        import cookielib
76        cj = cookielib.CookieJar() 
77        #return str(cj)
78        cookies = request.cookies.items()
79        resp = ""
80        for (k, v) in cookies:
81            resp += "<b>%s</b> = %s<br>" % (k, v)
82
83        import Cookie
84        k = Cookie.SimpleCookie()
85        k["ndg.security.session"] = "96bb6499953f3853bd4c36564fa6e266f239b11f232902baee883ece2ac5e73d91fdcbbb"
86
87        return resp
Note: See TracBrowser for help on using the repository browser.