This docs on this page refers to a PREVIOUS VERSION. For the latest stable release, go to https://docs.bokeh.org/

Archived docs for versions <= 1.0.4 have had to be modified from their original published configuration, and may be missing some features (e.g. source listing)

All users are encourage to update to version 1.1 or later, as soon as they are able.

bokeh.protocol.messages.push_doc — Bokeh 1.0.3 documentation

Source code for bokeh.protocol.messages.push_doc

#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2018, Anaconda, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Boilerplate
#-----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
log = logging.getLogger(__name__)

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

# Standard library imports

# External imports

# Bokeh imports
from ..exceptions import ProtocolError
from ..message import Message
from . import register

#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------

__all__ = (
    'push_doc_1',
)

#-----------------------------------------------------------------------------
# General API
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Dev API
#-----------------------------------------------------------------------------

[docs]@register class push_doc_1(Message): ''' Define the ``PUSH-DOC`` message (revision 1) for pushing Documents from clients to a Bokeh server. The ``content`` fragment of for this message is has the form: .. code-block:: python { 'doc' : <Document JSON> } ''' msgtype = 'PUSH-DOC' revision = 1 def __init__(self, header, metadata, content): super(push_doc_1, self).__init__(header, metadata, content)
[docs] @classmethod def create(cls, document, **metadata): ''' ''' header = cls.create_header() content = { 'doc' : document.to_json() } msg = cls(header, metadata, content) return msg
[docs] def push_to_document(self, doc): ''' Raises: ProtocolError ''' if 'doc' not in self.content: raise ProtocolError("No doc in PUSH-DOC") doc.replace_with_json(self.content['doc'])
#----------------------------------------------------------------------------- # Private API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Code #-----------------------------------------------------------------------------