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

Issue 144 attachment: couchdb.diff (3.4 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
diff -r fa57ba4e2fdb couchdb/client.py
--- a/couchdb/client.py Thu Aug 05 19:51:04 2010 +0200
+++ b/couchdb/client.py Thu Aug 05 17:54:35 2010 +0000
@@ -13,9 +13,9 @@
>>> doc_id, doc_rev = db.save({'type': 'Person', 'name': 'John Doe'})
>>> doc = db[doc_id]
>>> doc['type']
-'Person'
+u'Person'
>>> doc['name']
-'John Doe'
+u'John Doe'
>>> del db[doc.id]
>>> doc.id in db
False
@@ -230,18 +230,18 @@

>>> doc = db[doc_id]
>>> doc #doctest: +ELLIPSIS
- <Document '...'@... {...}>
+ <Document u'...'@u'...' {...}>

Documents are represented as instances of the `Row` class, which is
basically just a normal dictionary with the additional attributes ``id`` and
``rev``:

>>> doc.id, doc.rev #doctest: +ELLIPSIS
- ('...', ...)
+ (u'...', u'...')
>>> doc['type']
- 'Person'
+ u'Person'
>>> doc['name']
- 'John Doe'
+ u'John Doe'

To update an existing document, you use item access, too:

@@ -497,7 +497,7 @@
>>> db.delete(doc)
Traceback (most recent call last):
...
- ResourceConflict: ('conflict', 'Document update conflict.')
+ ResourceConflict: (u'conflict', u'Document update conflict.')

>>> del server['python-tests']

@@ -691,9 +691,9 @@
... Document(type='City', name='Gotham City')
... ]):
... print repr(doc) #doctest: +ELLIPSIS
- (True, '...', '...')
- (True, '...', '...')
- (True, '...', '...')
+ (True, u'...', u'...')
+ (True, u'...', u'...')
+ (True, u'...', u'...')

>>> del server['python-tests']

@@ -953,7 +953,7 @@
can still return multiple rows:

>>> list(results[['City', 'Gotham City']])
- [<Row id='gotham', key=['City', 'Gotham City'], value='Gotham City'>]
+ [<Row id=u'gotham', key=[u'City', u'Gotham City'], value=u'Gotham City'>]

>>> del server['python-tests']
"""
diff -r fa57ba4e2fdb couchdb/design.py
--- a/couchdb/design.py Thu Aug 05 19:51:04 2010 +0200
+++ b/couchdb/design.py Thu Aug 05 17:54:35 2010 +0000
@@ -42,7 +42,7 @@

>>> design_doc = view.get_doc(db)
>>> design_doc #doctest: +ELLIPSIS
- <Document '_design/tests'@'...' {...}>
+ <Document u'_design/tests'@u'...' {...}>
>>> print design_doc['views']['all']['map']
function(doc) {
emit(doc._id, null);
@@ -57,7 +57,7 @@
>>> view.sync(db)
>>> design_doc = view.get_doc(db)
>>> design_doc #doctest: +ELLIPSIS
- <Document '_design/test2'@'...' {...}>
+ <Document u'_design/test2'@u'...' {...}>
>>> print design_doc['views']['somename']['map']
def my_map(doc):
yield doc['somekey'], doc['somevalue']
diff -r fa57ba4e2fdb couchdb/mapping.py
--- a/couchdb/mapping.py Thu Aug 05 19:51:04 2010 +0200
+++ b/couchdb/mapping.py Thu Aug 05 17:54:35 2010 +0000
@@ -554,7 +554,7 @@
>>> post.author.email
u'john@doe.com'
>>> post.extra
- {'foo': 'bar'}
+ {u'foo': u'bar'}

>>> del server['python-tests']
"""
@@ -604,11 +604,11 @@
>>> post = Post.load(db, post.id)
>>> comment = post.comments[0]
>>> comment['author']
- 'myself'
+ u'myself'
>>> comment['content']
- 'Bla bla'
+ u'Bla bla'
>>> comment['time'] #doctest: +ELLIPSIS
- '...T...Z'
+ u'...T...Z'

>>> del server['python-tests']
"""
Powered by Google Project Hosting