diff options
| author | Bob Van Zant <b@brkt.com> | 2012-07-27 09:19:32 -0700 |
|---|---|---|
| committer | Bob Van Zant <b@brkt.com> | 2012-07-27 09:19:32 -0700 |
| commit | d6473f051644cc13f4ca9ad5b5cb563cf7f0d5f6 (patch) | |
| tree | bde161dee8124064d8366ead22c217763fd61a45 /docs/basic_usage.rst | |
| parent | 160b5680d22bd1d201b78815ac7886169b31de7b (diff) | |
| download | kazoo-d6473f051644cc13f4ca9ad5b5cb563cf7f0d5f6.tar.gz | |
Basic get + set example.
Uses json for serialization and defaults for everything.
Diffstat (limited to 'docs/basic_usage.rst')
| -rw-r--r-- | docs/basic_usage.rst | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/docs/basic_usage.rst b/docs/basic_usage.rst index 92688df..67ec078 100644 --- a/docs/basic_usage.rst +++ b/docs/basic_usage.rst @@ -4,4 +4,29 @@ Basic Usage =========== -TODO - not yet written +.. code-block:: python + + import json + import kazoo.client + + # No parameters assumes you want to connect to zookeeper on localhost:2181 + # Make sure zookeeper is actually running there. + # For more information: + # http://kazoo.readthedocs.org/en/latest/api/client.html#kazoo.client.KazooClient + zk = kazoo.client.KazooClient() + zk.connect() + + node_name = '/kazoo/test' + zk.ensure_path(node_name) + (json_data, zstat) = zk.get(node_name) + if json_data: + data = json.loads(json_data) + print 'Found goodies at', node_name + print data + else: + print 'No goodies found, setting some' + blob = { + 'name': 'Nicholas', + 'age': 1, + } + zk.set(node_name, json.dumps(blob)) |
