Show More
@@ -1,26 +1,16 b'' | |||||
1 | """Base class for a Comm""" |
|
1 | """Base class for a Comm""" | |
2 |
|
2 | |||
3 | #----------------------------------------------------------------------------- |
|
3 | # Copyright (c) IPython Development Team. | |
4 | # Copyright (C) 2013 The IPython Development Team |
|
4 | # Distributed under the terms of the Modified BSD License. | |
5 | # |
|
|||
6 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
7 | # the file COPYING, distributed as part of this software. |
|
|||
8 | #----------------------------------------------------------------------------- |
|
|||
9 |
|
||||
10 | #----------------------------------------------------------------------------- |
|
|||
11 | # Imports |
|
|||
12 | #----------------------------------------------------------------------------- |
|
|||
13 |
|
5 | |||
14 | import uuid |
|
6 | import uuid | |
15 |
|
7 | |||
16 | from IPython.config import LoggingConfigurable |
|
8 | from IPython.config import LoggingConfigurable | |
17 | from IPython.core.getipython import get_ipython |
|
9 | from IPython.core.getipython import get_ipython | |
18 |
|
10 | |||
|
11 | from IPython.utils.jsonutil import json_clean | |||
19 | from IPython.utils.traitlets import Instance, Unicode, Bytes, Bool, Dict, Any |
|
12 | from IPython.utils.traitlets import Instance, Unicode, Bytes, Bool, Dict, Any | |
20 |
|
13 | |||
21 | #----------------------------------------------------------------------------- |
|
|||
22 | # Code |
|
|||
23 | #----------------------------------------------------------------------------- |
|
|||
24 |
|
14 | |||
25 | class Comm(LoggingConfigurable): |
|
15 | class Comm(LoggingConfigurable): | |
26 |
|
16 | |||
@@ -69,9 +59,10 b' class Comm(LoggingConfigurable):' | |||||
69 | """Helper for sending a comm message on IOPub""" |
|
59 | """Helper for sending a comm message on IOPub""" | |
70 | data = {} if data is None else data |
|
60 | data = {} if data is None else data | |
71 | metadata = {} if metadata is None else metadata |
|
61 | metadata = {} if metadata is None else metadata | |
|
62 | content = json_clean(dict(data=data, comm_id=self.comm_id, **keys)) | |||
72 | self.session.send(self.iopub_socket, msg_type, |
|
63 | self.session.send(self.iopub_socket, msg_type, | |
73 | dict(data=data, comm_id=self.comm_id, **keys), |
|
64 | content, | |
74 | metadata=metadata, |
|
65 | metadata=json_clean(metadata), | |
75 | parent=self.shell.get_parent(), |
|
66 | parent=self.shell.get_parent(), | |
76 | ident=self.topic, |
|
67 | ident=self.topic, | |
77 | ) |
|
68 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now