Commits

Anonymous committed 0f96c51

make changes for new restkit

  • Participants
  • Parent commits e594e9d
  • Branches threadsafe

Comments (0)

Files changed (2)

File couchdbkit/client.py

     """
     
     def __init__(self, uri='http://127.0.0.1:5984', uuid_batch_count=DEFAULT_UUID_BATCH_COUNT, 
-            transport=None):
+            transport=None, use_proxy=False, min_size=0, max_size=4, pool_class=None):
         """ constructor for Server object
         
         @param uri: uri of CouchDb host
         @param uuid_batch_count: max of uuids to get in one time
         @param transport: an transport instance from :mod:`restkit.transport`. Can be used
                 to manage authentification to your server or proxy.
+        @param use_proxy: boolean, default is False, if you want to use a proxy
+        @param min_size: minimum number of connections in the pool
+        @param max_size: maximum number of connection in the pool
+        @param pool_class: custom pool class
         """
         
         if not uri or uri is None:
 
         self.uri = uri
         self.transport = transport
+        self.use_proxy = use_proxy
+        self.min_size = min_size
+        self.max_size = max_size
+        self.pool_class = pool_class
         self.uuid_batch_count = uuid_batch_count
         self._uuid_batch_count = uuid_batch_count
         
-        self.res = CouchdbResource(uri, transport=transport)
+        self.res = CouchdbResource(uri, transport=transport, use_proxy=use_proxy,
+            min_size=min_size, max_size=max_size, pool_class=pool_class)
         self.uuids = []
         
     def info(self, _raw_json=False):

File couchdbkit/resource.py

 
 class CouchdbResource(restkit.Resource):
 
-    def __init__(self, uri="http://127.0.0.1:5984", transport=None):
+    def __init__(self, uri="http://127.0.0.1:5984", transport=None, 
+            use_proxy=False, min_size=0, max_size=4, pool_class=None, **kwargs):
         """Constructor for a `CouchdbResource` object.
 
         CouchdbResource represent an HTTP resource to CouchDB.
                 a client based on `Httplib2 <http://code.google.com/p/httplib2/>`_ 
                 or make your own depending on the options you need to access the 
                 server (authentification, proxy, ....).
+        @param use_proxy: boolean, default is False, if you want to use a proxy
+        @param min_size: minimum number of connections in the pool
+        @param max_size: maximum number of connection in the pool
+        @param pool_class: custom pool class
         """
         
-        restkit.Resource.__init__(self, uri=uri, transport=transport)
+        restkit.Resource.__init__(self, uri=uri, transport=transport, 
+                use_proxy=use_proxy, min_size=min_size, max_size=max_size, 
+                pool_class=pool_class)
         self.client.safe = ":/"
 
+    def clone(self):
+        obj = self.__class__(uri=self.uri, transport=self.transport,
+                use_proxy=self.use_proxy, min_size=self.min_size, 
+                max_size=self.max_size, pool_class=self.pool_class)
+        return obj
+        
     def copy(self, path=None, headers=None, **params):
         """ add copy to HTTP verbs """
         return self.request('COPY', path=path, headers=headers, **params)
                 body = payload
 
         params = self.encode_params(params)
-
         def _make_request(retry=1):
             try:
                 return restkit.Resource.request(self, method, path=path,
-                        payload=body, headers=headers, _stream=_stream, 
-                        _stream_size=_stream_size, **params)
+                                 payload=body, headers=headers, _stream=_stream, 
+                                 _stream_size=_stream_size, **params)
             except (socket.error, httplib.BadStatusLine), e:
                 if retry > 0:
                     time.sleep(0.4)
                         response=HTTPResponse({}))
             except:
                 raise
+        
+
         try:
             data = _make_request()
         except restkit.RequestFailed, e: