Changeset 2690 for package_branches/invirt-web
- Timestamp:
- Dec 20, 2009, 9:45:38 PM (15 years ago)
- Location:
- package_branches/invirt-web/cherrypy-rebased/code
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy-rebased/code/main.py
r2689 r2690 56 56 'from invirt import database'] 57 57 58 def __getattr__(self, name): 59 if name in ("admin", "overlord"): 60 if not cherrypy.request.login in getAfsGroupMembers(config.adminacl, config.authz[0].cell): 61 raise InvalidInput('username', cherrypy.request.login, 62 'Not in admin group %s.' % config.adminacl) 63 cherrypy.request.state = State(cherrypy.request.login, isadmin=True) 64 return self 65 else: 66 return super(InvirtWeb, self).__getattr__(name) 58 67 59 68 @cherrypy.expose … … 646 655 'hostname' : socket.getfqdn()}]) 647 656 648 def admin(username, state, path, fields):649 if path == '':650 return ({'Status': '303 See Other',651 'Location': 'admin/'},652 "You shouldn't see this message.")653 if not username in getAfsGroupMembers(config.adminacl, 'athena.mit.edu'):654 raise InvalidInput('username', username,655 'Not in admin group %s.' % config.adminacl)656 newstate = State(username, isadmin=True)657 newstate.environ = state.environ658 return handler(username, newstate, path, fields)659 660 657 mapping = dict( 661 658 modify=modify, 662 unauth=unauthFront, 663 admin=admin, 664 overlord=admin) 659 unauth=unauthFront) 665 660 666 661 def printHeaders(headers): -
package_branches/invirt-web/cherrypy-rebased/code/templates/skeleton.mako
r2678 r2690 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; … … 49 49 % if not simple: 50 50 % if cherrypy.request.login: 51 <p class="loggedin">Welcome, <span class="name">${cherrypy.request.login}</span>.</p> 51 <p class="loggedin">Welcome, <span class="name">${cherrypy.request.login}</span>. 52 % if cherrypy.request.state.isadmin: 53 You are currently authenticated as an administrator. 54 % endif 55 </p> 52 56 % endif 53 57 -
package_branches/invirt-web/cherrypy-rebased/code/view.py
r2685 r2690 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.