My favorites | Sign in
Project Home
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 155 attachment: enhanced-delete.diff (1.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
diff -r 7084d62ee773 couchdb/client.py
--- a/couchdb/client.py Fri Mar 04 10:56:43 2011 +0000
+++ b/couchdb/client.py Mon Mar 14 02:44:56 2011 +0300
@@ -521,6 +521,9 @@
...
ResourceConflict: ('conflict', 'Document update conflict.')

+ >>> db.delete(doc2)
+ >>> doc2 #doctest: +ELLIPSIS
+ <Document 'johndoe'@'...' {'_deleted': True}>
>>> del server['python-tests']

:param doc: a dictionary or `Document` object holding the document data
@@ -529,7 +532,12 @@
"""
if doc['_id'] is None:
raise ValueError('document ID cannot be None')
- self.resource.delete_json(doc['_id'], rev=doc['_rev'])
+ _, _, data = self.resource.delete_json(doc['_id'], rev=doc['_rev'])
+
+ if data['ok']:
+ doc.clear()
+
+ doc.update(_id=data['id'], _rev=data['rev'], _deleted=True)

def get(self, id, default=None, **options):
"""Return the document with the specified ID.
@@ -876,6 +884,14 @@
"""
return self['_rev']

+ @property
+ def deleted(self):
+ """The document deletion status.
+
+ :rtype: bool
+ """
+ return self.get('_deleted', False)
+

class View(object):
"""Abstract representation of a view or query."""
Powered by Google Project Hosting