cubicweb/server/serverctl.py
changeset 12884 9754c40c732a
parent 12825 71a842bdf81d
--- a/cubicweb/server/serverctl.py	Wed Mar 13 00:01:35 2019 +0100
+++ b/cubicweb/server/serverctl.py	Fri Mar 15 21:35:59 2019 +0100
@@ -26,6 +26,7 @@
 
 from logilab.common.configuration import Configuration, merge_options
 from logilab.common.shellutils import ASK, generate_password
+from logilab.common.deprecation import deprecated
 
 from logilab.database import get_db_helper, get_connection
 
@@ -96,6 +97,9 @@
     return cnx
 
 
+@deprecated('[3.28] instead of system_source_cnx(source, True, **args) use '
+            'source_cnx(source, get_db_helper(source[\'db-driver\']).system_database(), '
+            '**args)')
 def system_source_cnx(source, dbms_system_base=False,
                       special_privs='CREATE/DROP DATABASE', interactive=True):
     """shortcut to get a connextion to the instance system database
@@ -118,8 +122,9 @@
     import logilab.common as lgp
     lgp.USE_MX_DATETIME = False
     # connect on the dbms system base to create our base
-    cnx = system_source_cnx(source, True, special_privs=special_privs,
-                            interactive=interactive)
+    system_db = get_db_helper(source['db-driver']).system_database()
+    cnx = source_cnx(source, system_db, special_privs=special_privs,
+                     interactive=interactive)
     # disable autocommit (isolation_level(1)) because DROP and
     # CREATE DATABASE can't be executed in a transaction
     set_isolation_level = getattr(cnx, 'set_isolation_level', None)
@@ -201,7 +206,7 @@
 @contextmanager
 def db_transaction(source, privilege):
     """Open a transaction to the instance database"""
-    cnx = system_source_cnx(source, special_privs=privilege)
+    cnx = source_cnx(source, special_privs=privilege)
     cursor = cnx.cursor()
     try:
         yield cursor
@@ -379,8 +384,8 @@
             except BaseException:
                 dbcnx.rollback()
                 raise
-        cnx = system_source_cnx(source, special_privs='CREATE LANGUAGE/SCHEMA',
-                                interactive=not automatic)
+        cnx = source_cnx(source, special_privs='CREATE LANGUAGE/SCHEMA',
+                         interactive=not automatic)
         cursor = cnx.cursor()
         helper.init_fti_extensions(cursor)
         namespace = source.get('db-namespace')
@@ -572,7 +577,7 @@
         config = ServerConfiguration.config_for(appid)
         source = config.system_source_config
         set_owner = self.config.set_owner
-        cnx = system_source_cnx(source, special_privs='GRANT')
+        cnx = source_cnx(source, special_privs='GRANT')
         cursor = cnx.cursor()
         schema = config.load_schema()
         try: