[dataio] provide compatibility with CW 3.19 (closes #279602)
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 24 Nov 2014 10:06:26 +0100
changeset 489 010d03707a5f
parent 488 afd0c31334e2
child 490 eb99225b4167
[dataio] provide compatibility with CW 3.19 (closes #279602) ``config.sources()`` doesn't exist anymore in CW 3.19, we should use the ``config.default_admin_config`` dictionary instead.
utils/dataio.py
--- a/utils/dataio.py	Mon Nov 24 10:03:14 2014 +0100
+++ b/utils/dataio.py	Mon Nov 24 10:06:26 2014 +0100
@@ -57,11 +57,15 @@
     """ Get a cnx on a CubicWeb database
     """
     from cubicweb import dbapi
+    from cubicweb.__pkginfo__ import numversion
     from cubicweb.cwconfig import CubicWebConfiguration
     from cubicweb.entities import AnyEntity
     CubicWebConfiguration.load_cwctl_plugins()
     config = CubicWebConfiguration.config_for(endpoint)
-    sourceinfo = config.sources()['admin']
+    if numversion < (3, 19):
+        sourceinfo = config.sources()['admin']
+    else:
+        sourceinfo = config.default_admin_config
     login = sourceinfo['login']
     password = sourceinfo['password']
     _, cnx = dbapi.in_memory_repo_cnx(config, login, password=password)