[dbapi] fix for cases where one want to use 'connect' for an in-memory connection stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 17 Feb 2011 16:08:19 +0100
branchstable
changeset 7004 9e142116d82f
parent 7003 6eeed1e9782c
child 7005 f45f42256905
[dbapi] fix for cases where one want to use 'connect' for an in-memory connection
dbapi.py
--- a/dbapi.py	Thu Feb 17 16:08:09 2011 +0100
+++ b/dbapi.py	Thu Feb 17 16:08:19 2011 +0100
@@ -168,16 +168,20 @@
       where it's already initialized.
 
     :kwargs:
-      there goes authentication tokens. You usually have to specify for
-      instance a password for the given user, using a named 'password' argument.
+      there goes authentication tokens. You usually have to specify a password
+      for the given user, using a named 'password' argument.
     """
-    config = cwconfig.CubicWebNoAppConfiguration()
-    if host:
-        config.global_set_option('pyro-ns-host', host)
-    if group:
-        config.global_set_option('pyro-ns-group', group)
     cnxprops = cnxprops or ConnectionProperties()
     method = cnxprops.cnxtype
+    if method == 'pyro':
+        config = cwconfig.CubicWebNoAppConfiguration()
+        if host:
+            config.global_set_option('pyro-ns-host', host)
+        if group:
+            config.global_set_option('pyro-ns-group', group)
+    else:
+        assert database
+        config = cwconfig.instance_configuration(database)
     repo = get_repository(method, database, config=config)
     if method == 'inmemory':
         vreg = repo.vreg