Avoid per-request global state.
authorEric Price <ecprice@mit.edu>
Tue, 3 Jun 2008 03:59:50 +0000 (23:59 -0400)
committerEric Price <ecprice@mit.edu>
Tue, 3 Jun 2008 03:59:50 +0000 (23:59 -0400)
svn path=/trunk/packages/sipb-xen-www/; revision=578

code/main.py
code/webcommon.py

index 70e9a2a..620c0b9 100755 (executable)
@@ -41,7 +41,7 @@ import sipb_xen_database
 from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type, Autoinstall
 import validation
 import cache_acls
 from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type, Autoinstall
 import validation
 import cache_acls
-from webcommon import InvalidInput, CodeError, state
+from webcommon import InvalidInput, CodeError, State
 import controls
 
 class Checkpoint:
 import controls
 
 class Checkpoint:
@@ -667,7 +667,7 @@ if __name__ == '__main__':
         logging.getLogger('sqlalchemy.orm.unitofwork').setLevel(logging.INFO)
 
     username = getUser(os.environ)
         logging.getLogger('sqlalchemy.orm.unitofwork').setLevel(logging.INFO)
 
     username = getUser(os.environ)
-    state.username = username
+    state = State(username)
     operation = os.environ.get('PATH_INFO', '')
     if not operation:
         print "Status: 301 Moved Permanently"
     operation = os.environ.get('PATH_INFO', '')
     if not operation:
         print "Status: 301 Moved Permanently"
index 5911787..9a9453a 100644 (file)
@@ -54,5 +54,3 @@ class State(object):
         for attr in list(self.__dict__):
             if attr.startswith('__cache_'):
                 delattr(self, attr)
         for attr in list(self.__dict__):
             if attr.startswith('__cache_'):
                 delattr(self, attr)
-
-state = State(None)