<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Python API</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>Recent changes to Python API</description><atom:link href="https://sourceforge.net/p/dbis/wiki/Python%20API/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 11 Nov 2015 12:04:32 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/dbis/wiki/Python%20API/feed" rel="self" type="application/rss+xml"/><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v14
+++ v15
@@ -7,6 +7,16 @@

 * `dbis-cachemgr` must be running.
 * Python program must have permission to connect to DBIS client socket (default is `/var/run/dbis/client`).
+
+Online documentation is available through pydoc, e.g.
+
+~~~~
+$ python
+&amp;gt;&amp;gt;&amp;gt; import dbis.client, dbis.client.api
+&amp;gt;&amp;gt;&amp;gt; help(dbis.client)
+&amp;gt;&amp;gt;&amp;gt; help(dbis.client.opts)
+&amp;gt;&amp;gt;&amp;gt; help(dbis.client.api)
+~~~~

 By default the data is returned by the API as a list of strings in short format.  Here is a simple example that looks up a single host entry:

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 11 Nov 2015 12:04:32 -0000</pubDate><guid>https://sourceforge.net83e96d8d1314c8369bb5b8178ce0f83c4bd2c19a</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v13
+++ v14
@@ -148,8 +148,8 @@
 Keyword | Value | Description
 ------- | ----- | -----------
 `format` | `dbisopts.NSS` | Change output format to NSS-style.  This is the default output style.
-`format` | `dbisopts.STR` | Change output format to string representation of Python dictionary.
-`format` | `dbisopts.PICKLE` | Change output format to pickled representation of Python dictionary.  The Python API will unpickle the data before returning to the caller.
+`format` | `dbisopts.STR` | Change output format to string representation of Python data type.
+`format` | `dbisopts.PICKLE` | Change output format to pickled representation of Python data type.  The Python API will unpickle the data before returning to the caller.
 `format` | `dbisopts.STREAM` | Change output format to binary data stream, the format used by the NSS library.
 `format` | `dbisopts.JSON` | Change output format to JSON.
 `getnetgrent_recurse` | `True` | Request that a subsequent `getnetgrent` lookup should recurse member netgroups.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Thu, 16 Apr 2015 06:15:25 -0000</pubDate><guid>https://sourceforge.net0f79f9113373b50dbb614d747fa7b0b02663f901</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v12
+++ v13
@@ -133,7 +133,7 @@
 -----------------------
 It is possible to modify the data that the `dbis-cachemgr` server sends back to the client.  This is achieved using options that are passed through by the `dbis.client.lookup()` method to the server socket.

-These messages are set-up in a `dbis.client.opts.Options` object that is passed to the `opts` parameter to `dbis.client.initialise()` or `dbis.client.lookup()`.  For example, to request that the result should be returned as a Python object (i.e. pickled during transfer) and sorted:
+These messages are set-up in a `dbis.client.opts.Options` object that is passed to the `opts` parameter to `dbis.client.initialise()` or `dbis.client.lookup()`.  For example, to request that the result should be returned as a Python data type (i.e. pickled during transfer) and sorted:

 ~~~~
 #!/usr/bin/python
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 16:28:52 -0000</pubDate><guid>https://sourceforge.net9f1ccf01b63282d7ed04db7bc758763a550d7364</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v11
+++ v12
@@ -33,7 +33,7 @@
 10.11.12.14     kilcher
 ~~~~

-This output is good for display purposes, but not so good for parsing.  If the data is to be parsed, it would be better represented as a Python object.  This can also be achieved, by requesting that the server sends the data to the client in Python pickle format.  Note that the data will be unpickled before it is returned from the API:
+This output is good for display purposes, but not so good for parsing.  If the data is to be parsed, it would be better represented as a Python tuple or dictionary.  This can also be achieved, by requesting that the server sends the data to the client in Python pickle format.  Note that the data will be unpickled before it is returned from the API:

 ~~~~
 #!/usr/bin/python
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 16:26:23 -0000</pubDate><guid>https://sourceforge.netc0994c8361b1a625cb8accdea5bb0fa32436a77e</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v10
+++ v11
@@ -33,7 +33,7 @@
 10.11.12.14     kilcher
 ~~~~

-This output is good for display purposes, but not so good for parsing.  If the data is to be parsed, it would be better represented as a Python dictionary.  This can also be achieved, by requesting that the server sends the data to the client in Python pickle format.  Note that the data will be unpickled before it is returned from the API:
+This output is good for display purposes, but not so good for parsing.  If the data is to be parsed, it would be better represented as a Python object.  This can also be achieved, by requesting that the server sends the data to the client in Python pickle format.  Note that the data will be unpickled before it is returned from the API:

 ~~~~
 #!/usr/bin/python
@@ -80,7 +80,7 @@

 The dictionary of attributes contains the attribute type (key) and a list of values.

-If `dbisapi.gethostbyname()` were called with no specific key, the entire map will be iterated instead.  In this case, if pickle format is requested, the resulting data structure will differ to that of a single value:
+If `dbisapi.gethostbyname()` were called with no specific key, the entire map will be iterated instead.  In this case, if pickle format is requested, the resulting unpickled data structure will differ to that of a single value:

 ~~~~
 {None: (None, 1429078604.586754, 900),
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 16:25:25 -0000</pubDate><guid>https://sourceforge.net0d3e52a97ee3959dd2e71c33b4ba60f51d5688c1</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v9
+++ v10
@@ -48,7 +48,7 @@
 # Set-up options
 opts = dbisopts.Options(format=dbisopts.PICKLE)

-# Lookup entry in NSS format
+# Lookup full entry
 cmdobj = dbisapi.gethostbyname("kilcher")
 result = client.lookup(cmdobj, opts)
 print result
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 16:09:17 -0000</pubDate><guid>https://sourceforge.netb98f8014a554985e9893efaaa4e4a8a10c33510a</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v8
+++ v9
@@ -6,8 +6,7 @@
 The Python API is designed to allow DBIS maps to be queried efficiently from within a third party Python program.  The API has the following pre-requisites:

 * `dbis-cachemgr` must be running.
-* Python program must be configured with DBIS client socket address (default is `/var/run/dbis/client`).
-* Python program must have permission to connect to DBIS client socket.
+* Python program must have permission to connect to DBIS client socket (default is `/var/run/dbis/client`).

 By default the data is returned by the API as a list of strings in short format.  Here is a simple example that looks up a single host entry:

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 16:00:36 -0000</pubDate><guid>https://sourceforge.neted140d47addafa00270442dc972f2da9f98d53b7</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -152,6 +152,7 @@
 `format` | `dbisopts.STR` | Change output format to string representation of Python dictionary.
 `format` | `dbisopts.PICKLE` | Change output format to pickled representation of Python dictionary.  The Python API will unpickle the data before returning to the caller.
 `format` | `dbisopts.STREAM` | Change output format to binary data stream, the format used by the NSS library.
+`format` | `dbisopts.JSON` | Change output format to JSON.
 `getnetgrent_recurse` | `True` | Request that a subsequent `getnetgrent` lookup should recurse member netgroups.
 `getnetgrent_recurse` | `False` | Request that a subsequent `getnetgrent` lookup should not recurse member netgroups, i.e. netgroup members will be listed by netgroup name.  This is the default.
 `sort` | `True` | Result should be sorted.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 06:35:51 -0000</pubDate><guid>https://sourceforge.net0d8e60d9ca3d3caaa3da0eac5e4001473d1ba0ec</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 06:32:10 -0000</pubDate><guid>https://sourceforge.net89756726963ed8abfb25644c059091ac00a2663b</guid></item><item><title>Python API modified by Mark R. Bannister</title><link>https://sourceforge.net/p/dbis/wiki/Python%2520API/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -61,7 +61,10 @@
 DEBUG: connecting to /var/run/dbis/client
 DEBUG: sending command: 'set format=pickle\ngethostbyname kilcher\n'
 DEBUG: unpickling result
-(('rn=kilcher,ou=lab,ou=hosts,o=infra', {'objectClass': ['top', 'ipHostObject', 'ipv4HostObject', 'ieee802Device'], 'ipv4Address': ['10.11.12.14'], 'rn': ['kilcher'], '_cfgmap': ['cn=hosts,en=sales.corp,ou=domain-mappings,o=infra'], 'macAddress': ['08:00:27:00:50:f2']}), 1429078281.088914, 900)
+(('rn=kilcher,ou=lab,ou=hosts,o=infra', {'objectClass': ['top', 'ipHostObject',
+'ipv4HostObject', 'ieee802Device'], 'ipv4Address': ['10.11.12.14'], 'rn':
+['kilcher'], '_cfgmap': ['cn=hosts,en=sales.corp,ou=domain-mappings,o=infra'],
+'macAddress': ['08:00:27:00:50:f2']}), 1429078281.088914, 900)
 ~~~~

 The result is a tuple containing a tuple containing a dictionary.  The outermost tuple contains:
@@ -95,7 +98,8 @@
              900),
 ... &amp;lt;snip&amp;gt; ...
  'www6.aja.com': (('cn=peg6.aja.com,ou=rfc2307,o=infra',
-                   {'_cfgmap': ['cn=hosts-legacy,ou=rfc2307,en=sales.corp,ou=domain-mappings,o=infra'],
+                   {'_cfgmap': ['cn=hosts-legacy,ou=rfc2307,en=sales.corp,
+ou=domain-mappings,o=infra'],
                     'bootFile': ['mach'],
                     'bootParameter': ['root=fs:/nfsroot/peg',
                                       'swap=fs:/nfsswap/peg',
@@ -140,7 +144,7 @@
 print opts.get()
 ~~~~

-The supported paramters to `dbis.client.opts.Options` are summarised in the table below.
+The supported parameters to `dbis.client.opts.Options` are summarised in the table below.

 Keyword | Value | Description
 ------- | ----- | -----------
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark R. Bannister</dc:creator><pubDate>Wed, 15 Apr 2015 06:31:14 -0000</pubDate><guid>https://sourceforge.netd0b0138eb8c5065dc7be2a6083c8a80bc6f29571</guid></item></channel></rss>