fix bulk updates twisty
authorMark Hammond <mhammond@skippinet.com.au>
Sat, 28 Mar 2009 17:30:34 +1100
branchtwisty
changeset 128 f95653d4377dcb27c75805dd631523d86d2c38f3
parent 127 06207d46f9c97313ebeb868d3cf72e14a2a83094
child 129 8704eacfbfb6f0baad8d6202fee770c10491d350
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
fix bulk updates
server/python/junius/model.py
--- a/server/python/junius/model.py
+++ b/server/python/junius/model.py
@@ -64,16 +64,19 @@ class CouchDB(paisley.CouchDB):
         # directly does?
         body = json.dumps(ob, allow_nan=False,
                           ensure_ascii=False).encode('utf-8')
         return self.post(uri, body)
 
     def openView(self, *args, **kwargs):
         # The base class of this returns the raw json object - eg:
         # {'rows': [], 'total_rows': 0}
+        # XXX - Note that paisley isn't interested in this enhancement, so
+        # we need to remove it...
+
         # *sob* - and it also doesn't handle encoding options...
         return super(CouchDB, self).openView(*args, **_encode_options(kwargs)
                         ).addCallback(_raw_to_rows)
 
     def openDoc(self, dbName, docId, revision=None, full=False, attachment=""):
         # paisley appears to use an old api for attachments?
         if attachment:
             uri = "/%s/%s/%s" % (dbName, docId, attachment)
@@ -124,22 +127,22 @@ class CouchDB(paisley.CouchDB):
         factory = HTTPClientFactory(url, **kwargs)
         from twisted.internet import reactor
         reactor.connectTCP(self.host, self.port, factory)
         d = factory.deferred
         # ** end of self._getPage clone **
         d.addCallback(self.parseResult)
         return d
 
-    def updateDocuments(self, dbName, docs):
+    def updateDocuments(self, dbName, user_docs):
         # update/insert/delete multiple docs in a single request using
         # _bulk_docs
         # from couchdb-python.
         docs = []
-        for doc in docs:
+        for doc in user_docs:
             if isinstance(doc, dict):
                 docs.append(doc)
             elif hasattr(doc, 'items'):
                 docs.append(dict(doc.items()))
             else:
                 raise TypeError('expected dict, got %s' % type(doc))
         url = "/%s/_bulk_docs" % dbName
         body = json.dumps({'docs': docs})