Skip to content

Commit 211d56e

Browse files
committed
Documentation update; small pep8 changes to client.py
1 parent eee2785 commit 211d56e

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

README.rst

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ Atomic Compare and Swap
7878
client.write('/nodes/n2', 2, prevIndex = 30) # will set /nodes/n2 's value to 2 only if the key was last modified at index 30
7979
client.test_and_set('/nodes/n2', 2, 4) #equivalent to client.write('/nodes/n2', 2, prevValue = 4)
8080
81+
You can also atomically update a result:
82+
83+
.. code:: python
84+
85+
result = client.read('/foo')
86+
print(result.value) # bar
87+
result.value += u'bar'
88+
updated = client.update(result) # if any other client wrote '/foo' in the meantime this will fail
89+
print(updated.value) # barbar
8190
8291
Watch a key
8392
~~~~~~~~~~~

docs-source/index.rst

+12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ Set a key
6262
client.write('/nodes/queue', 'test', append=True) #will write i.e. /nodes/queue/11
6363
client.write('/nodes/queue', 'test2', append=True) #will write i.e. /nodes/queue/12
6464
65+
You can also atomically update a result:
66+
67+
.. code:: python
68+
69+
result = client.read('/foo')
70+
print(result.value) # bar
71+
result.value += u'bar'
72+
updated = client.update(result) # if any other client wrote '/foo' in the meantime this will fail
73+
print(updated.value) # barbar
74+
75+
76+
6577
Get a key
6678
.........
6779

src/etcd/client.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,16 @@ def delete(self, key, recursive=None, dir=None, **kwdargs):
348348
349349
key (str): Key.
350350
351-
recursive (bool): if we want to recursively delete a directory, set it to true
351+
recursive (bool): if we want to recursively delete a directory, set
352+
it to true
352353
353354
dir (bool): if we want to delete a directory, set it to true
354355
355-
prevValue (str): compare key to this value, and swap only if corresponding (optional).
356+
prevValue (str): compare key to this value, and swap only if
357+
corresponding (optional).
356358
357-
prevIndex (int): modify key only if actual modifiedIndex matches the provided one (optional).
359+
prevIndex (int): modify key only if actual modifiedIndex matches the
360+
provided one (optional).
358361
359362
Returns:
360363
client.EtcdResult
@@ -527,7 +530,7 @@ def _next_server(self):
527530
except IndexError:
528531
raise etcd.EtcdException('No more machines in the cluster')
529532

530-
def api_execute(self, path, method, params=None, timeout=None):
533+
def api_execute(self, path, method, params=None, timeout=None):
531534
""" Executes the query. """
532535

533536
some_request_failed = False

0 commit comments

Comments
 (0)