def create_db(self, dbname): """ Create a database on CouchDb host @param dname: str, name of db @return: Database instance if it's ok or dict message """ _dbname = resource.url_quote(dbname, safe="") res = self.res.put('/%s/' % _dbname) if res['ok']: dburl = resource.make_uri(self.url, "/%s" % _dbname) return Database(self.ui, dburl, server=self) return res['ok']
def __iter__(self): for dbname in self.all_dbs(): dburl = resource.make_uri(self.url, "/%s" % dbname) yield Database(self.ui, dburl, server=self)
def __getitem__(self, dbname): if dbname in self: dburl = resource.make_uri(self.url, "/%s" % dbname) return Database(self.ui, dburl, server=self) raise ResourceNotFound("database %s not found" % dbname)