[migration] remove repo_connect and use config.repository() instead
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 09 Jul 2014 17:52:45 +0200
changeset 10569 af47954c1015
parent 10568 3914388b2d0f
child 10570 c0501d4f67f1
[migration] remove repo_connect and use config.repository() instead One less more redundant path to the repo. Related to #3933480.
cwctl.py
devtools/testlib.py
migration.py
server/migractions.py
server/serverctl.py
--- a/cwctl.py	Wed Jul 09 16:32:14 2014 +0200
+++ b/cwctl.py	Wed Jul 09 17:52:45 2014 +0200
@@ -767,7 +767,7 @@
             set_sources_mode(self.config.ext_sources or ('migration',))
         # get instance and installed versions for the server and the componants
         mih = config.migration_handler()
-        repo = mih.repo_connect()
+        repo = mih.repo
         vcconf = repo.get_versions()
         helper = self.config_helper(config, required=False)
         if self.config.force_cube_version:
@@ -856,8 +856,7 @@
         config.quick_start = True
         if hasattr(config, 'set_sources_mode'):
             config.set_sources_mode(('migration',))
-        repo = config.migration_handler().repo_connect()
-        vcconf = repo.get_versions()
+        vcconf = config.repository().get_versions()
         for key in sorted(vcconf):
             print key+': %s.%s.%s' % vcconf[key]
 
--- a/devtools/testlib.py	Wed Jul 09 16:32:14 2014 +0200
+++ b/devtools/testlib.py	Wed Jul 09 17:52:45 2014 +0200
@@ -313,7 +313,6 @@
         login = unicode(db_handler.config.default_admin_config['login'])
         self.admin_access = self.new_access(login)
         self._admin_session = self.admin_access._session
-        self.config.repository = lambda x=None: self.repo
 
 
     # config management ########################################################
--- a/migration.py	Wed Jul 09 16:32:14 2014 +0200
+++ b/migration.py	Wed Jul 09 17:52:45 2014 +0200
@@ -139,9 +139,6 @@
             raise
         raise AttributeError(name)
 
-    def repo_connect(self):
-        return self.config.repository()
-
     def migrate(self, vcconf, toupgrade, options):
         """upgrade the given set of cubes
 
--- a/server/migractions.py	Wed Jul 09 16:32:14 2014 +0200
+++ b/server/migractions.py	Wed Jul 09 17:52:45 2014 +0200
@@ -96,7 +96,7 @@
             self.repo = repo
             self.session = cnx.session
         elif connect:
-            self.repo_connect()
+            self.repo = config.repository()
             self.set_cnx()
         else:
             self.session = None
@@ -152,12 +152,6 @@
                 sys.exit(0)
         self.session = self.repo._get_session(self.cnx.sessionid)
 
-
-    @cached
-    def repo_connect(self):
-        self.repo = repoapi.get_repository(config=self.config)
-        return self.repo
-
     def cube_upgraded(self, cube, version):
         self.cmd_set_property('system.version.%s' % cube.lower(),
                               unicode(version))
@@ -194,7 +188,7 @@
 
     def backup_database(self, backupfile=None, askconfirm=True, format='native'):
         config = self.config
-        repo = self.repo_connect()
+        repo = self.repo
         # paths
         timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
         instbkdir = osp.join(config.appdatahome, 'backup')
@@ -271,7 +265,7 @@
                 if written_format in ('portable', 'native'):
                     format = written_format
         self.config.init_cnxset_pool = False
-        repo = self.repo_connect()
+        repo = self.repo
         source = repo.system_source
         try:
             source.restore(osp.join(tmpdir, source.uri), self.confirm, drop, format)
--- a/server/serverctl.py	Wed Jul 09 16:32:14 2014 +0200
+++ b/server/serverctl.py	Wed Jul 09 17:52:45 2014 +0200
@@ -696,7 +696,7 @@
     config.quick_start = True
     mih = config.migration_handler(connect=False, verbosity=1)
     mih.restore_database(backupfile, drop, askconfirm=False, format=format)
-    repo = mih.repo_connect()
+    repo = mih.repo
     # version of the database
     dbversions = repo.get_versions()
     mih.shutdown()