]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
Merge branch 'master' into fix-authz
authorEvan Broder <broder@mit.edu>
Mon, 8 Jun 2009 04:16:38 +0000 (21:16 -0700)
committerEvan Broder <broder@mit.edu>
Mon, 8 Jun 2009 04:16:38 +0000 (21:16 -0700)
bluechips/config/deployment.ini_tmpl
bluechips/lib/permissions.py

index aac0095abda96f52442a8191baff6a58fb826bcf..7cf3cf108405ef825ee465f376462853f332f01e 100644 (file)
@@ -32,6 +32,10 @@ app_instance_uuid = ${app_instance_uuid}
 sqlalchemy.url = sqlite:///production.db
 sqlalchemy.echo = False
 
+# If you're using MySQL, uncomment this line to avoid the "MySQL
+# server has gone away" error
+#sqlalchemy.pool_recycle = 3600
+
 # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
 # Debug mode will enable the interactive debugging tool, allowing ANYONE to
 # execute malicious code after an exception is raised.
index d2a9e8c8b0e64260143a6a470fc356e8b2552808..63c9c5c0241a495990bdd9ca4abe6aeba4391b36 100644 (file)
@@ -6,8 +6,6 @@ from authkit.authenticate import AddDictToEnviron
 from authkit.authorize import NotAuthenticatedError, NotAuthorizedError
 from authkit.permissions import RequestPermission
 
-from sqlalchemy.exceptions import InvalidRequestError
-
 from bluechips import model
 from bluechips.model import meta
 
@@ -15,11 +13,10 @@ class BlueChipUser(RequestPermission):
     def check(self, app, environ, start_response):
         if 'REMOTE_USER' not in environ:
             raise NotAuthenticatedError('Not Authenticated')
-        try:
-            environ['user'] = meta.Session.query(model.User).\
-                filter_by(username=unicode(environ['REMOTE_USER'])).\
-                one()
-        except InvalidRequestError:
+        environ['user'] = meta.Session.query(model.User).\
+            filter_by(username=unicode(environ['REMOTE_USER'])).\
+            first()
+        if environ['user'] == None:
             raise NotAuthorizedError('You are not allowed access.')
         return app(environ, start_response)