Show More
@@ -756,13 +756,51 b' Message type: ``display_data``::' | |||
|
756 | 756 | # The data dict contains key/value pairs, where the kids are MIME |
|
757 | 757 | # types and the values are the raw data of the representation in that |
|
758 | 758 | # format. The data dict must minimally contain the ``text/plain`` |
|
759 |
# MIME type which is used as a backup representation. |
|
|
759 | # MIME type which is used as a backup representation. | |
|
760 | 760 | 'data' : dict, |
|
761 | 761 | |
|
762 | 762 | # Any metadata that describes the data |
|
763 | 763 | 'metadata' : dict |
|
764 | 764 | } |
|
765 | 765 | |
|
766 | ||
|
767 | Raw Data Publication | |
|
768 | -------------------- | |
|
769 | ||
|
770 | ``display_data`` lets you publish *representations* of data, such as images and html. | |
|
771 | This ``data_pub`` message lets you publish *actual raw data*, sent via message buffers. | |
|
772 | ||
|
773 | data_pub messages are constructed via the :func:`IPython.lib.datapub.publish_data` function: | |
|
774 | ||
|
775 | .. sourcecode:: python | |
|
776 | ||
|
777 | from IPython.zmq.datapub import publish_data | |
|
778 | ns = dict(x=my_array) | |
|
779 | publish_data(ns) | |
|
780 | ||
|
781 | ||
|
782 | Message type: ``data_pub``:: | |
|
783 | ||
|
784 | content = { | |
|
785 | # the keys of the data dict, after it has been unserialized | |
|
786 | keys = ['a', 'b'] | |
|
787 | } | |
|
788 | # the namespace dict will be serialized in the message buffers, | |
|
789 | # which will have a length of at least one | |
|
790 | buffers = ['pdict', ...] | |
|
791 | ||
|
792 | ||
|
793 | The interpretation of a sequence of data_pub messages for a given parent request should be | |
|
794 | to update a single namespace with subsequent results. | |
|
795 | ||
|
796 | .. note:: | |
|
797 | ||
|
798 | No frontends directly handle data_pub messages at this time. | |
|
799 | It is currently only used by the client/engines in :mod:`IPython.parallel`, | |
|
800 | where engines may publish *data* to the Client, | |
|
801 | of which the Client can then publish *representations* via ``display_data`` | |
|
802 | to various frontends. | |
|
803 | ||
|
766 | 804 | Python inputs |
|
767 | 805 | ------------- |
|
768 | 806 |
General Comments 0
You need to be logged in to leave comments.
Login now