Commits

Anonymous committed d1fb0dd

create db from full url without passing dbname. spotted by @davisp on
irc.

  • Participants
  • Parent commits 94da77b
  • Branches 0.10x

Comments (0)

Files changed (2)

couchdbkit/client.py

         return "<%s %s>" % (self.__class__.__name__, self.dbname)
         
     @classmethod
-    def from_uri(cls, uri, dbname, uuid_batch_count=DEFAULT_UUID_BATCH_COUNT, 
-                transport=None):
+    def from_uri(cls, uri, uuid_batch_count=DEFAULT_UUID_BATCH_COUNT, 
+                transport=None, use_proxy=False, min_size=0, max_size=4, pool_class=None):
         """ Create a database from its url. """
-        server_uri = uri.split(dbname)[0][:-1]
+        server_uri, dbname = uri.rsplit("/", 1)
         server = Server(server_uri, uuid_batch_count=uuid_batch_count, 
             transport=transport)
-        return cls(server, dbname)
+        return server.get_or_create_db(dbname)
         
     def info(self, _raw_json=False):
         """

tests/client_test.py

     def testDbFromUri(self):
         db = self.Server.create_db('couchdbkit_test')
         
-        db1 = Database.from_uri("http://127.0.0.1:5984/couchdbkit_test", "couchdbkit_test")
+        db1 = Database.from_uri("http://127.0.0.1:5984/couchdbkit_test")
         self.assert_(hasattr(db1, "dbname") == True)
         self.assert_(db1.dbname == "couchdbkit_test")
         info = db1.info()