@@ -40,12 +40,15 @@ class CouchDB(dict):
4040
4141 :param str user: Username used to connect to CouchDB.
4242 :param str auth_token: Authentication token used to connect to CouchDB.
43- :param str url: URL for CouchDB server.
4443 :param bool admin_party: Setting to allow the use of Admin Party mode in
4544 CouchDB. Defaults to ``False``.
45+ :param str url: URL for CouchDB server.
4646 :param str encoder: Optional json Encoder object used to encode
4747 documents for storage. Defaults to json.JSONEncoder.
48- :param requests.HTTPAdapter adapter: Optional adapter to use for configuring requests.
48+ :param requests.HTTPAdapter adapter: Optional adapter to use for
49+ configuring requests.
50+ :param bool connect: Keyword argument, if set to True performs the call to
51+ connect as part of client construction. Default is False.
4952 """
5053 _DATABASE_CLASS = CouchDatabase
5154
@@ -60,12 +63,17 @@ def __init__(self, user, auth_token, admin_party=False, **kwargs):
6063 self .encoder = kwargs .get ('encoder' ) or json .JSONEncoder
6164 self .adapter = kwargs .get ('adapter' )
6265 self .r_session = None
66+ if kwargs .get ('connect' , False ):
67+ self .connect ()
6368
6469 def connect (self ):
6570 """
6671 Starts up an authentication session for the client using cookie
67- authentication.
72+ authentication if necessary .
6873 """
74+ if self .r_session :
75+ return
76+
6977 self .r_session = requests .Session ()
7078 # If a Transport Adapter was supplied add it to the session
7179 if self .adapter is not None :
0 commit comments