Ignore:
Timestamp:
Sep 27, 2009, 7:55:09 PM (15 years ago)
Author:
quentin
Message:

Implement administrator mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy/code/main.py

    r2481 r2482  
    6262                                                 'from invirt import database']
    6363
     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)
    6473
    6574    @cherrypy.expose
     
    701710            'hostname' : socket.getfqdn()}])
    702711
    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.environ
    713     return handler(username, newstate, path, fields)
    714 
    715712mapping = dict(
    716713               modify=modify,
    717                unauth=unauthFront,
    718                admin=admin,
    719                overlord=admin)
     714               unauth=unauthFront)
    720715
    721716def printHeaders(headers):
Note: See TracChangeset for help on using the changeset viewer.