changeset 2717:dd240b2b7a12 beta

Added optional flag to make_ui to not clean sqlalchemy Session. Don't clear sqlalchemy session when using make_ui in admin repo form
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 15 Aug 2012 18:25:38 +0200
parents 4c71667160e5
children 82fb2a161ddf
files rhodecode/lib/utils.py rhodecode/model/validators.py
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/utils.py	Wed Aug 15 00:22:53 2012 +0200
+++ b/rhodecode/lib/utils.py	Wed Aug 15 18:25:38 2012 +0200
@@ -280,7 +280,7 @@
                 'ui', 'web', ]
 
 
-def make_ui(read_from='file', path=None, checkpaths=True):
+def make_ui(read_from='file', path=None, checkpaths=True, clear_session=True):
     """
     A function that will read python rc files or database
     and make an mercurial ui object from read options
@@ -325,8 +325,8 @@
                 # force set push_ssl requirement to False, rhodecode
                 # handles that
                 baseui.setconfig(ui_.ui_section, ui_.ui_key, False)
-
-        meta.Session.remove()
+        if clear_session:
+            meta.Session.remove()
     return baseui
 
 
--- a/rhodecode/model/validators.py	Wed Aug 15 00:22:53 2012 +0200
+++ b/rhodecode/model/validators.py	Wed Aug 15 18:25:38 2012 +0200
@@ -377,10 +377,10 @@
                 ## initially check if it's at least the proper URL
                 ## or does it pass basic auth
                 MercurialRepository._check_url(url)
-                httppeer(make_ui('db'), url)._capabilities()
+                httppeer(ui, url)._capabilities()
             elif url.startswith('svn+http'):
                 from hgsubversion.svnrepo import svnremoterepo
-                svnremoterepo(make_ui('db'), url).capabilities
+                svnremoterepo(ui, url).capabilities
             elif url.startswith('git+http'):
                 raise NotImplementedError()
 
@@ -410,7 +410,7 @@
                 pass
             else:
                 try:
-                    url_handler(repo_type, url, make_ui('db'))
+                    url_handler(repo_type, url, make_ui('db', clear_session=False))
                 except Exception:
                     log.exception('Url validation failed')
                     msg = M(self, 'clone_uri')