You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/02/27 17:18:20 UTC
[03/16] git commit: [#7210] Skip flush before restoring Ming session
extensions on error
[#7210] Skip flush before restoring Ming session extensions on error
Signed-off-by: Cory Johns <cj...@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/7ba3fb79
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7ba3fb79
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7ba3fb79
Branch: refs/heads/cj/7210
Commit: 7ba3fb794a3c8ff04b8637a0394309de69bc4ad6
Parents: e3af39b
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Feb 24 22:05:53 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Feb 25 21:28:53 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/7ba3fb79/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')