From 4ce8c973ed05312a146354a93786480582d4e363 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 20 Dec 2009 17:26:48 -0500 Subject: [PATCH] Setup hosting for static resources in the InvirtWeb and InvirtUnauthWeb classes, instead of in the fcgi configuration. svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2730 --- code/auth.fcgi | 5 ----- code/main.py | 12 ++++++++++++ code/unauth.fcgi | 5 ----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/code/auth.fcgi b/code/auth.fcgi index e48729a..97a7551 100755 --- a/code/auth.fcgi +++ b/code/auth.fcgi @@ -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(), diff --git a/code/main.py b/code/main.py index 3be15a6..207ba98 100755 --- a/code/main.py +++ b/code/main.py @@ -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): diff --git a/code/unauth.fcgi b/code/unauth.fcgi index 841da6a..f37c914 100755 --- a/code/unauth.fcgi +++ b/code/unauth.fcgi @@ -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(), -- 1.7.9.5