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

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

various fixes on bbox etc

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