incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#7210] Skip flush before restoring Ming session extensions on error
Date Mon, 24 Feb 2014 22:06:24 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/cj/7210 [created] 0022b3452


[#7210] Skip flush before restoring Ming session extensions on error

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0022b345
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0022b345
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0022b345

Branch: refs/heads/cj/7210
Commit: 0022b34526a73ba883465c97f74fe03bc1261216
Parents: ab5f24b
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Mon Feb 24 22:05:53 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Feb 24 22:05:53 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/session.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0022b345/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 68c8099..b14eb8e 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -177,15 +177,21 @@ def substitute_extensions(session, extensions=None):
     """
     original_exts = session._kwargs.get('extensions', [])
 
-    def _set_exts(exts):
-        session.flush()
-        session.close()
-        session._kwargs['extensions'] = exts
-    _set_exts(extensions or [])
+    def _set_exts(exts, flush):
+        try:
+            if flush:
+                session.flush()
+                session.close()
+        finally:
+            session._kwargs['extensions'] = exts
+    _set_exts(extensions or [], True)
     try:
         yield session
-    finally:
-        _set_exts(original_exts)
+    except:
+        _set_exts(original_exts, False)
+        raise
+    else:
+        _set_exts(original_exts, True)
 
 
 main_doc_session = Session.by_name('main')


Mime
View raw message