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.
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
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)