Setup hosting for static resources in the InvirtWeb and
authorEvan Broder <broder@mit.edu>
Sun, 20 Dec 2009 22:26:48 +0000 (17:26 -0500)
committerEvan Broder <broder@mit.edu>
Sun, 20 Dec 2009 22:26:48 +0000 (17:26 -0500)
InvirtUnauthWeb classes, instead of in the fcgi configuration.

svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2730

code/auth.fcgi
code/main.py
code/unauth.fcgi

index e48729a..97a7551 100755 (executable)
@@ -35,11 +35,6 @@ if __name__ == "__main__":
         '/': {
             'tools.invirtwebstate.on': True,
             },
-        '/static': {
-            'tools.staticdir.root': static_dir,
-            'tools.staticdir.on': True,
-            'tools.staticdir.dir': static_dir,
-            }
         }
                     
     app = cherrypy.tree.mount(InvirtWeb(),
index 3be15a6..207ba98 100755 (executable)
@@ -6,6 +6,7 @@ import cPickle
 import cgi
 import datetime
 import hmac
+import os
 import random
 import sha
 import sys
@@ -37,7 +38,16 @@ from invirt.common import InvalidInput, CodeError
 
 from view import View, revertStandardError
 
+
+static_dir = os.path.join(os.path.dirname(__file__), 'static')
+InvirtStatic = cherrypy.tools.staticdir.handler(
+    root=static_dir,
+    dir=static_dir,
+    section='/static')
+
 class InvirtUnauthWeb(View):
+    static = InvirtStatic
+
     @cherrypy.expose
     @cherrypy.tools.mako(filename="/unauth.mako")
     def index(self):
@@ -53,6 +63,8 @@ class InvirtWeb(View):
                                                  'from invirt import database']
         self._cp_config['request.error_response'] = self.handle_error
 
+    static = InvirtStatic
+
     @cherrypy.expose
     @cherrypy.tools.mako(filename="/invalid.mako")
     def invalidInput(self):
index 841da6a..f37c914 100755 (executable)
@@ -35,11 +35,6 @@ if __name__ == "__main__":
         '/': {
             'tools.invirtwebstate.on': True,
             },
-        '/static': {
-            'tools.staticdir.root': static_dir,
-            'tools.staticdir.on': True,
-            'tools.staticdir.dir': static_dir,
-            }
         }
                     
     app = cherrypy.tree.mount(InvirtUnauthWeb(),