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 Tue, 25 Feb 2014 15:03:27 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/cj/7210 0022b3452 -> 0ec702191 (forced update)


[#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/0ec70219
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0ec70219
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0ec70219

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

----------------------------------------------------------------------
 Allura/allura/model/session.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0ec70219/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 68c8099..50bbb8a 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -177,15 +177,20 @@ 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 [])
+    # flush the session to ensure everything so far
+    # is written using the original extensions
+    session.flush()
+    session.close()
     try:
+        session._kwargs['extensions'] = extensions or []
         yield session
+        # if successful, flush the session to ensure everything
+        # new is written using the modified extensions
+        session.flush()
+        session.close()
     finally:
-        _set_exts(original_exts)
+        # restore proper session extension even if everything goes horribly awry
+        session._kwargs['extensions'] = original_exts
 
 
 main_doc_session = Session.by_name('main')


Mime
View raw message