From: Eric Price Date: Tue, 3 Jun 2008 03:59:50 +0000 (-0400) Subject: Avoid per-request global state. X-Git-Tag: sipb-xen-www/3.6~63 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/commitdiff_plain/b6ac16dfe45437378c5683777e4e20283219803a Avoid per-request global state. svn path=/trunk/packages/sipb-xen-www/; revision=578 --- diff --git a/code/main.py b/code/main.py index 70e9a2a..620c0b9 100755 --- a/code/main.py +++ b/code/main.py @@ -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 webcommon import InvalidInput, CodeError, state +from webcommon import InvalidInput, CodeError, State import controls class Checkpoint: @@ -667,7 +667,7 @@ if __name__ == '__main__': 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" diff --git a/code/webcommon.py b/code/webcommon.py index 5911787..9a9453a 100644 --- a/code/webcommon.py +++ b/code/webcommon.py @@ -54,5 +54,3 @@ class State(object): for attr in list(self.__dict__): if attr.startswith('__cache_'): delattr(self, attr) - -state = State(None)