You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.
def update(self, documents):
documents = list(documents)
data = self.resource.post('_bulk_docs', content=documents)
for idx, result in enumerate(data['results']):
assert 'ok' in result # FIXME: how should error handling work here?
doc = documents[idx]
doc.update({'_id': result['id'], '_rev': result['rev']})
yield doc
This won't perform the POST until the first result is asked for. I'm not
sure if this is a bug or intentional as iterating the result has other side
effects too. It just seemed a bit spooky and confused me for a while.
If iterating is optional, I think something like the following would
make sure the update is always called when the function is called while
preserving the current usage.
def update(self, documents):
documents = list(documents)
data = self.resource.post('_bulk_docs', content=documents)
def foo():
for idx, result in enumerate(data['results']):
assert 'ok' in result # FIXME: how should error handling
work here?
doc = documents[idx]
doc.update({'_id': result['id'], '_rev': result['rev']})
yield doc
return foo()
From melk...@gmail.com on February 06, 2008 23:36:14
def update(self, documents):
documents = list(documents)
data = self.resource.post('_bulk_docs', content=documents)
for idx, result in enumerate(data['results']):
assert 'ok' in result # FIXME: how should error handling work here?
doc = documents[idx]
doc.update({'_id': result['id'], '_rev': result['rev']})
yield doc
This won't perform the POST until the first result is asked for. I'm not
sure if this is a bug or intentional as iterating the result has other side
effects too. It just seemed a bit spooky and confused me for a while.
If iterating is optional, I think something like the following would
make sure the update is always called when the function is called while
preserving the current usage.
def update(self, documents):
documents = list(documents)
data = self.resource.post('_bulk_docs', content=documents)
def foo():
for idx, result in enumerate(data['results']):
assert 'ok' in result # FIXME: how should error handling
work here?
doc = documents[idx]
doc.update({'_id': result['id'], '_rev': result['rev']})
yield doc
return foo()
Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=5
The text was updated successfully, but these errors were encountered: