From 2a5fd2a74ab63d8df3e95fd1adf22eda04f0473d 2011-01-24 05:29:41 From: Brian Granger Date: 2011-01-24 05:29:41 Subject: [PATCH] Initial version of DisplayPublisher is working. * Backend and frontend implementations. * plain text, html and svg handlers in the Qt console. --- diff --git a/IPython/core/displaypub.py b/IPython/core/displaypub.py new file mode 100644 index 0000000..375ddb5 --- /dev/null +++ b/IPython/core/displaypub.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +"""An interface for publishing data related to the display of objects. + +Authors: + +* Brian Granger +""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2008-2010 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +from IPython.config.configurable import Configurable + +#----------------------------------------------------------------------------- +# Main payload class +#----------------------------------------------------------------------------- + +class DisplayPublisher(Configurable): + + def _validate_data(self, source, data, metadata=None): + if not isinstance(source, str): + raise TypeError('source must be a str, got: %r' % source) + if not isinstance(data, dict): + raise TypeError('data must be a dict, got: %r' % data) + if metadata is not None: + if not isinstance(metadata, dict): + raise TypeError('metadata must be a dict, got: %r' % data) + + def publish(self, source, data, metadata=None): + """Publish data and metadata to all frontends.""" + pass +