Class Server
object --+
|
Server
Representation of a CouchDB server.
>>> server = Server('http://localhost:5984/')
This class behaves like a dictionary of databases. For example, to get a
list of database names on the server, you can simply iterate over the
server object.
New databases can be created using the create method:
>>> db = server.create('python-tests')
>>> db
<Database 'python-tests'>
You can access existing databases using item access, specifying the database
name as the key:
>>> db = server['python-tests']
>>> db.name
'python-tests'
Databases can be deleted using a del statement:
>>> del server['python-tests']
|
__init__(self,
uri=' http://localhost:5984/ ' ,
cache=None,
timeout=None)
Initialize the server object. |
|
|
|
__contains__(self,
name)
Return whether the server contains a database with the specified
name. |
|
|
|
__iter__(self)
Iterate over the names of all databases. |
|
|
|
__len__(self)
Return the number of databases. |
|
|
|
__nonzero__(self)
Return whether the server is available. |
|
|
|
|
|
__delitem__(self,
name)
Remove the database with the specified name. |
|
|
Database
|
__getitem__(self,
name)
Return a Database object representing the database with the
specified name. |
|
|
Database
|
create(self,
name)
Create a new database with the given name. |
|
|
|
delete(self,
name)
Delete the database with the specified name. |
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__str__
|
dict
|
config
The configuration of the CouchDB server.
|
unicode
|
version
The version string of the CouchDB server.
|
Inherited from object :
__class__
|
__init__(self,
uri=' http://localhost:5984/ ' ,
cache=None,
timeout=None)
(Constructor)
|
|
Initialize the server object.
- Parameters:
uri - the URI of the server (for example
http://localhost:5984/)
cache - either a cache directory path (as a string) or an object
compatible with the httplib2.FileCache interface. If
None (the default), no caching is performed.
timeout - socket timeout in number of seconds, or None for no
timeout
- Overrides:
object.__init__
|
__contains__(self,
name)
(In operator)
|
|
Return whether the server contains a database with the specified
name.
- Parameters:
- Returns:
True if a database with the name exists, False otherwise
|
__repr__(self)
(Representation operator)
|
|
repr(x)
- Overrides:
object.__repr__
- (inherited documentation)
|
__delitem__(self,
name)
(Index deletion operator)
|
|
Remove the database with the specified name.
- Parameters:
name - the name of the database
- Raises:
|
__getitem__(self,
name)
(Indexing operator)
|
|
Return a Database object representing the database with the
specified name.
- Parameters:
name - the name of the database
- Returns: Database
- a Database object representing the database
- Raises:
|
Create a new database with the given name.
- Parameters:
name - the name of the database
- Returns: Database
- a Database object representing the created database
- Raises:
|
Delete the database with the specified name.
- Parameters:
name - the name of the database
- Raises:
|
config
The configuration of the CouchDB server.
The configuration is represented as a nested dictionary of sections and
options from the configuration files of the server, or the default
values for options that are not explicitly configured.
- Get Method:
- unreachable.config(self)
- The configuration of the CouchDB server.
- Type:
dict
|
version
The version string of the CouchDB server.
Note that this results in a request being made, and can also be used
to check for the availability of the server.
- Get Method:
- unreachable.version(self)
- The version string of the CouchDB server.
- Type:
unicode
|