Skip to content

Instantly share code, notes, and snippets.

@Xjs
Created March 13, 2010 11:08
Show Gist options
  • Save Xjs/331255 to your computer and use it in GitHub Desktop.
Save Xjs/331255 to your computer and use it in GitHub Desktop.
diff --git a/couchdbkit/client.py b/couchdbkit/client.py
index dbf9e10..3d1988e 100644
--- a/couchdbkit/client.py
+++ b/couchdbkit/client.py
@@ -223,10 +225,7 @@ class Database(object):
uri_parsed = urlparse.urlparse(uri)
server_uri = "%s://%s" % (uri_parsed.scheme, uri_parsed.netloc)
- dbname = uri_parsed.path[1:]
- if dbname.endswith("/"):
- dbname = dbname[:-1]
- self.dbname = dbname
+ self.dbname = uri_parsed.path.strip("/")
if server is not None:
if not hasattr(server, 'next_uuid'):
@@ -237,17 +236,17 @@ class Database(object):
self.server = server = Server(server_uri)
try:
- server.res.head('/%s/' % url_quote(dbname, safe=":"))
+ server.res.head('/%s/' % url_quote(self.dbname, safe=":"))
except resource.ResourceNotFound:
if create:
- server.res.put('/%s/' % url_quote(dbname, safe=":"))
+ server.res.put('/%s/' % url_quote(self.dbname, safe=":"))
else:
raise
self.res = server.res.clone()
- if "/" in dbname:
+ if "/" in self.dbname:
self.res.safe = ":/%"
- self.res.update_uri('/%s' % url_quote(dbname, safe=":"))
+ self.res.update_uri('/%s' % url_quote(self.dbname, safe=":"))
def __repr__(self):
return "<%s %s>" % (self.__class__.__name__, self.dbname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment