diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-01-28 13:10:01 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-02-28 20:52:35 +0100 |
commit | 2bc8ff0d63188f2168553d39ebf8756ae83053e1 (patch) | |
tree | 751c6cbd970f7be86ed3de38ef9c552d9402e563 /mediagoblin/app.py | |
parent | 3502958113c09c80830b7bee63c3d82b5ff72eb9 (diff) | |
download | mediagoblin-2bc8ff0d63188f2168553d39ebf8756ae83053e1.tar.lz mediagoblin-2bc8ff0d63188f2168553d39ebf8756ae83053e1.tar.xz mediagoblin-2bc8ff0d63188f2168553d39ebf8756ae83053e1.zip |
Cleanup Session after each request.
It's good practice to cleanup the SQL session after each
request so that the next request gets a fresh one.
It's an application decision whether one wants a
just-in-case ROLLBACK or COMMIT. There are two ideas behind
it, really. I have decided for ROLLBACK. The idea is "if
you forget to commit your changes yourself, there's
something broken. Maybe you got an exception?".
Diffstat (limited to 'mediagoblin/app.py')
-rw-r--r-- | mediagoblin/app.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 15327d39..0a57c091 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -184,6 +184,14 @@ class MediaGoblinApp(object): for m in self.meddleware[::-1]: m.process_response(request, response) + # Reset the sql session, so that the next request + # gets a fresh session + try: + self.db.reset_after_request() + except TypeError: + # We're still on mongo + pass + return response(environ, start_response) |