From 0df643a6effeb3923ff9bee96c07db19e4c4d261 2012-08-01 22:54:26 From: MinRK Date: 2012-08-01 22:54:26 Subject: [PATCH] document data_pub messages --- diff --git a/docs/source/development/messaging.txt b/docs/source/development/messaging.txt index d723b89..a46bce5 100644 --- a/docs/source/development/messaging.txt +++ b/docs/source/development/messaging.txt @@ -756,13 +756,51 @@ Message type: ``display_data``:: # The data dict contains key/value pairs, where the kids are MIME # types and the values are the raw data of the representation in that # format. The data dict must minimally contain the ``text/plain`` - # MIME type which is used as a backup representation. + # MIME type which is used as a backup representation. 'data' : dict, # Any metadata that describes the data 'metadata' : dict } + +Raw Data Publication +-------------------- + +``display_data`` lets you publish *representations* of data, such as images and html. +This ``data_pub`` message lets you publish *actual raw data*, sent via message buffers. + +data_pub messages are constructed via the :func:`IPython.lib.datapub.publish_data` function: + +.. sourcecode:: python + + from IPython.zmq.datapub import publish_data + ns = dict(x=my_array) + publish_data(ns) + + +Message type: ``data_pub``:: + + content = { + # the keys of the data dict, after it has been unserialized + keys = ['a', 'b'] + } + # the namespace dict will be serialized in the message buffers, + # which will have a length of at least one + buffers = ['pdict', ...] + + +The interpretation of a sequence of data_pub messages for a given parent request should be +to update a single namespace with subsequent results. + +.. note:: + + No frontends directly handle data_pub messages at this time. + It is currently only used by the client/engines in :mod:`IPython.parallel`, + where engines may publish *data* to the Client, + of which the Client can then publish *representations* via ``display_data`` + to various frontends. + Python inputs -------------