From 1d079163df57b9ba8d4f19fa1b80c07c46f3b2ef Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 9 May 2008 02:10:57 -0400 Subject: [PATCH 1/1] front page for non-MIT users (and other unath'd) svn path=/trunk/packages/sipb-xen-www/; revision=510 --- code/main.py | 16 +++++++++++++--- code/templates/__init__.py | 2 +- code/templates/unauth.tmpl | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 code/templates/unauth.tmpl diff --git a/code/main.py b/code/main.py index 9871088..24fe062 100755 --- a/code/main.py +++ b/code/main.py @@ -600,13 +600,18 @@ def info(user, fields): checkpoint.checkpoint('Got infodict') return templates.info(searchList=[d]) +def unauthFront(_, fields): + """Information for unauth'd users.""" + return templates.unauth(searchList=[{'simple' : True}]) + mapping = dict(list=listVms, vnc=vnc, command=command, modify=modify, info=info, create=create, - help=helpHandler) + help=helpHandler, + unauth=unauthFront) def printHeaders(headers): """Print a dictionary as HTTP headers.""" @@ -617,8 +622,10 @@ def printHeaders(headers): def getUser(): """Return the current user based on the SSL environment variables""" - username = os.environ['SSL_CLIENT_S_DN_Email'].split("@")[0] - return username + email = os.environ.get('SSL_CLIENT_S_DN_Email', None) + if email is None: + return None + return email.split("@")[0] def main(operation, user, fields): start_time = time.time() @@ -674,6 +681,9 @@ if __name__ == '__main__': print 'Location: ' + os.environ['SCRIPT_NAME']+'/\n' sys.exit(0) + if u is None: + operation = 'unauth' + if operation.startswith('/'): operation = operation[1:] if not operation: diff --git a/code/templates/__init__.py b/code/templates/__init__.py index 8e94be7..d26672f 100644 --- a/code/templates/__init__.py +++ b/code/templates/__init__.py @@ -1,4 +1,4 @@ -__all__ = 'info command error help invalid list vnc'.split() +__all__ = 'info command error help invalid list unauth vnc'.split() for _name in __all__: try: _module = __import__(_name, globals(), {}, [_name]) diff --git a/code/templates/unauth.tmpl b/code/templates/unauth.tmpl new file mode 100644 index 0000000..fb98440 --- /dev/null +++ b/code/templates/unauth.tmpl @@ -0,0 +1,32 @@ +#from skeleton import skeleton +#extends skeleton + + +#def title +Intro +#end def + +#def body +

XVM — Virtual Servers for MIT

+ +

xvm.mit.edu is a virtualization service for the +MIT community. We offer virtual machines—your +own complete system on which you can start from our two-minute +Debian Linux auto-install or install the operating +system of your choice. The service is free +to any Athena account holder.

+ +

If you're a member of the MIT community, go try out the service +now. You'll need an MIT personal +certificate.

+ +

xvm.mit.edu is provided by SIPB, +the student computing group at MIT, with generous +funding from IS&T. Like all +SIPB projects, we are independently run by our own team of volunteers, +and we welcome new contributors.

+ +

Questions and feedback welcome at xvm@mit.edu.

+ +#end def -- 1.7.9.5