Unauthenticated front page
authorQuentin Smith <quentin@mit.edu>
Mon, 28 Sep 2009 07:04:32 +0000 (03:04 -0400)
committerQuentin Smith <quentin@mit.edu>
Mon, 28 Sep 2009 07:04:32 +0000 (03:04 -0400)
svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2692

code/main.fcgi
code/main.py
code/templates/unauth.mako [moved from code/templates/unauth.tmpl with 90% similarity]

index cd10538..6f3ed99 100755 (executable)
@@ -4,7 +4,7 @@
 import cherrypy
 import os
 import sys
 import cherrypy
 import os
 import sys
-from main import InvirtWeb
+from main import InvirtWeb, InvirtUnauthWeb
 
 dev = False
 base_dir = os.path.dirname(__file__)
 
 dev = False
 base_dir = os.path.dirname(__file__)
@@ -25,6 +25,10 @@ if __name__=="__main__":
                     'tools.staticdir.dir': static_dir}
          })
     app.merge(conf_file)
                     'tools.staticdir.dir': static_dir}
          })
     app.merge(conf_file)
+    unauthApp = cherrypy.tree.mount(InvirtUnauthWeb(),
+                                    '/unauth',
+                                    {'/': {'tools.invirtwebstate.on': True}})
+    unauthApp.merge(conf_file)
     cherrypy.config.update(conf_file)
 
     if dev:
     cherrypy.config.update(conf_file)
 
     if dev:
@@ -34,5 +38,5 @@ if __name__=="__main__":
     else:
         cherrypy.engine.start(blocking=False)
         from flup.server.fcgi import WSGIServer
     else:
         cherrypy.engine.start(blocking=False)
         from flup.server.fcgi import WSGIServer
-        server = WSGIServer(app)
+        server = WSGIServer(cherrypy.tree)
         server.run()
         server.run()
index baf4ff9..361fbbd 100755 (executable)
@@ -47,6 +47,12 @@ from invirt.common import InvalidInput, CodeError
 
 from view import View
 
 
 from view import View
 
+class InvirtUnauthWeb(View):
+    @cherrypy.expose
+    @cherrypy.tools.mako(filename="/unauth.mako")
+    def index(self):
+        return {'simple': True}
+
 class InvirtWeb(View):
     def __init__(self):
         super(self.__class__,self).__init__()
 class InvirtWeb(View):
     def __init__(self):
         super(self.__class__,self).__init__()
@@ -654,13 +660,7 @@ def infoDict(username, state, machine):
              fields = fields)
     return d
 
              fields = fields)
     return d
 
-def unauthFront(_, _2, _3, fields):
-    """Information for unauth'd users."""
-    return templates.unauth(searchList=[{'simple' : True, 
-            'hostname' : socket.getfqdn()}])
-
-mapping = dict(
-               unauth=unauthFront)
+mapping = dict()
 
 def printHeaders(headers):
     """Print a dictionary as HTTP headers."""
 
 def printHeaders(headers):
     """Print a dictionary as HTTP headers."""
similarity index 90%
rename from code/templates/unauth.tmpl
rename to code/templates/unauth.mako
index 0715f2c..562481f 100644 (file)
@@ -1,12 +1,10 @@
-#from skeleton import skeleton
-#extends skeleton
+<%page expression_filter="h"/>
+<%inherit file="skeleton.mako" />
 
 
-
-#def title
+<%def name="title()">
 Intro
 Intro
-#end def
+</%def>
 
 
-#def body
 <h1>XVM &mdash; Virtual Servers for MIT </h1>
 
 <p><strong>xvm.mit.edu</strong> is a virtualization service for the
 <h1>XVM &mdash; Virtual Servers for MIT </h1>
 
 <p><strong>xvm.mit.edu</strong> is a virtualization service for the
@@ -18,7 +16,7 @@ to any Athena account holder.</p>
 
 <p>MIT users:</p>
 <blockquote><big><a
 
 <p>MIT users:</p>
 <blockquote><big><a
-href="https://$hostname/"><strong><font color="green">&rarr;</font> Log in to XVM now</strong>
+href="https://${config.web.hostname}/"><strong><font color="green">&rarr;</font> Log in to XVM now</strong>
 </a></big></blockquote>
 <p>You'll need an <a href="http://ca.mit.edu/">MIT personal
 certificate</a>.</p>
 </a></big></blockquote>
 <p>You'll need an <a href="http://ca.mit.edu/">MIT personal
 certificate</a>.</p>
@@ -56,5 +54,3 @@ contributors.</p>
 
 <p>Questions and feedback welcome at <a
 href="mailto:xvm@mit.edu">xvm@mit.edu</a>.</p>
 
 <p>Questions and feedback welcome at <a
 href="mailto:xvm@mit.edu">xvm@mit.edu</a>.</p>
-
-#end def