Changeset 2482
- Timestamp:
- Sep 27, 2009, 7:55:09 PM (15 years ago)
- Location:
- package_branches/invirt-web/cherrypy/code
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy/code/main.py
r2481 r2482 62 62 'from invirt import database'] 63 63 64 def __getattr__(self, name): 65 if name in ("admin", "overlord"): 66 if not cherrypy.request.login in getAfsGroupMembers(config.adminacl, config.authz[0].cell): 67 raise InvalidInput('username', cherrypy.request.login, 68 'Not in admin group %s.' % config.adminacl) 69 cherrypy.request.state = State(cherrypy.request.login, isadmin=True) 70 return self 71 else: 72 return super(InvirtWeb, self).__getattr__(name) 64 73 65 74 @cherrypy.expose … … 701 710 'hostname' : socket.getfqdn()}]) 702 711 703 def admin(username, state, path, fields):704 if path == '':705 return ({'Status': '303 See Other',706 'Location': 'admin/'},707 "You shouldn't see this message.")708 if not username in getAfsGroupMembers(config.adminacl, 'athena.mit.edu'):709 raise InvalidInput('username', username,710 'Not in admin group %s.' % config.adminacl)711 newstate = State(username, isadmin=True)712 newstate.environ = state.environ713 return handler(username, newstate, path, fields)714 715 712 mapping = dict( 716 713 modify=modify, 717 unauth=unauthFront, 718 admin=admin, 719 overlord=admin) 714 unauth=unauthFront) 720 715 721 716 def printHeaders(headers): -
package_branches/invirt-web/cherrypy/code/templates/skeleton.mako
r2432 r2482 6 6 <html> 7 7 <head><title>${self.title()} — XVM</title> 8 <base href="${cherrypy.request.base} " />9 <link href=" static/favicon.ico" type="image/x-icon" rel="shortcut icon">10 <link rel="stylesheet" href=" static/style.css" type="text/css" />11 <link rel="stylesheet" href=" static/layout.css" type="text/css" media="screen" />12 <script type="text/javascript" src=" static/prototype.js"></script>8 <base href="${cherrypy.request.base}${"/admin/" if cherrypy.request.state.isadmin else ""}" /> 9 <link href="/static/favicon.ico" type="image/x-icon" rel="shortcut icon"> 10 <link rel="stylesheet" href="/static/style.css" type="text/css" /> 11 <link rel="stylesheet" href="/static/layout.css" type="text/css" media="screen" /> 12 <script type="text/javascript" src="/static/prototype.js"></script> 13 13 <script type="text/javascript"> 14 14 var helpWin = null; … … 50 50 % if not simple: 51 51 % if cherrypy.request.login: 52 <p class="loggedin">Welcome, <span class="name">${cherrypy.request.login}</span>.</p> 52 <p class="loggedin">Welcome, <span class="name">${cherrypy.request.login}</span>. 53 % if cherrypy.request.state.isadmin: 54 You are currently authenticated as an administrator. 55 % endif 56 </p> 53 57 % endif 54 58 -
package_branches/invirt-web/cherrypy/code/view.py
r2422 r2482 113 113 def invirtwebstate_init(): 114 114 """Initialize the cherrypy.request.state object from Invirt""" 115 cherrypy.request.state = State(cherrypy.request.login) 115 if not hasattr(cherrypy.request, "state"): 116 cherrypy.request.state = State(cherrypy.request.login) 116 117 117 118 cherrypy.tools.invirtwebstate = cherrypy.Tool('on_start_resource', invirtwebstate_init, priority=100)
Note: See TracChangeset
for help on using the changeset viewer.