cloudant-labs / cloudant-python

Asynchronous Cloudant / CouchDB interface for Python
http://cloudant-labs.github.io/cloudant-python/
37 stars 17 forks source link

Get an error when ever I create a document #44

Open rramanadham opened 10 years ago

rramanadham commented 10 years ago

Hi,

I am using cloudant0.5.8 and python3.3, couchdb 1.5.1 on suse linux. and I get the error when ever I create a document. The document does get created, but i cant avoid the error.

I tried to debug the code, but i couldnt figure out.

Exception TypeError: TypeError('delete() takes 2 positional arguments but 3 were given',) in <bound method Design.del of <cloudant.design.Design object at 0x7f265f4f4dd0>> ignored

Can you help?

Thanks, Radhika

garbados commented 10 years ago

Can you post the code block that raises this error?

rramanadham commented 10 years ago

Here is my code-

I call createDesignDocForErrors() :

def createDesignDocForErrors():
    design = db.design(errors_view)
    resp = design.put(params={
        "_id":"_design/errors",
        "language": "javascript",
        "views":
        {
            "by_test_id": {
                #"map": "function(doc) { if (doc.type == 'error')  emit(doc.test_id, doc.errors) }"
                "map": "function(doc) { if (doc.type == 'error')  emit(doc.test_id, doc.error_count) }",
                "reduce" : "_sum"
            },

            #http://10.247.32.72:5984/longevity/_design/errors/_view/by_testid_starttime?group=true
            "by_testid_starttime": {
                "map": "function(doc) { if (doc.type == 'error')  emit([doc.test_id,doc.start_time], doc.error_count) }",
                "reduce" : "function(keys, values) {return (values[0])}"
            }
        }
     })

The last piece of code that gets executed before it returns to the caller- createDesignDocForErrors() is from cloudant/document.py at the line- "deletion = self.delete(self, doc['_rev'])"

def __del__(self):
        """
        Shortcut to synchronously deleting the document from the database.
        For example:

            del db['docKey']
        """
        response = self.get()
        # block until result if the object is using async/is a future
        if hasattr(response, 'result'):
            response = response.result()
        response.raise_for_status()
        doc = response.json()
        deletion = self.delete(self, doc['_rev'])
        # block until result if the object is using async/is a future
        if hasattr(deletion, 'result'):
            deletion = deletion.result()
        deletion.raise_for_status()
garbados commented 10 years ago

Where are you calling deletion = self.delete(self, doc['_rev'])? The line you posted doesn't call __del__.

rramanadham commented 10 years ago

I don't know why delete is called. I don't call it. However, I was suggested that cloudant 0.5.9 has the problem fixed. Just ran a test after I upgraded cloudant to 0.5.9 and I no more see the error.

https://api.github.com/repos/cloudant-labs/cloudant-python/commits/04609664e32f330a781bfb7a11a198f66980e30a

garbados commented 10 years ago

Ah, well, hooray!