Commits

Anonymous committed 4da6bcd

replaced method list_docs() with view_all_docs(), which accepts the same parameters as view()

  • Participants
  • Parent commits aab0387

Comments (0)

Files changed (1)

 
     # Document operations
     
-    def list_docs(self, raise_error=True):
-        '''Get dict with id and rev of all documents in the database.'''
-        resp = self._http_get(''.join(['/', self.db_name, '/_all_docs']), raise_error=raise_error)
-        return dict((row['id'], row['value']['rev']) for row in resp['rows'])
-
     def get_doc(self, doc_id, raise_error=True):
         '''Get document with the given id.'''
         url = ''.join(['/', self.db_name, '/', url_escape(doc_id)])
           inclusive_end=true
           inclusive_end=false
         '''
+        url = ''.join(['/', self.db_name, '/_design/', design_doc_name, '/_view/', view_name])
+        return self._view(url, raise_error=raise_error, **kwargs)
+
+    def view_all_docs(self, raise_error=True, **kwargs):
+        '''Query the _all_docs view.
+        Accepts same keyword parameters as view()
+        '''
+        url = ''.join(['/', self.db_name, '/_all_docs'])
+        return self._view(url, raise_error=raise_error, **kwargs)
+
+    def _view(self, url, raise_error=True, **kwargs):
         body = None
         options = []
         if kwargs:
                     value = url_escape(json_encode(value))
                     options.append('='.join([key, value]))
         if options:
-            q = '?' + '&'.join(options)
-        else:
-            q = ''
-        url = ''.join(['/', self.db_name, '/_design/', design_doc_name, '/_view/', view_name, q])
+            url = ''.join([url, '?', '&'.join(options)])
         if body:
             return self._http_post(url, body, raise_error=raise_error)
         else: