##// END OF EJS Templates
Make 'Paste Above' the default paste behavior....
Make 'Paste Above' the default paste behavior. Destructive paste mapped to Ctrl-M V is a surprising choice given that there was no drag-to-select on the area being replaced (there is a weaker notion of "selected cell" but this does not map to will-be-replaced- by-paste in the minds of participants in an unscientific poll at PyConCA). Destructive paste is still available as the last paste option in the Edit menu, qualified as "Paste Cell Replace".

File last commit:

r8107:5d37dff7
r8715:2a45e0e8
Show More
datapub.py
71 lines | 2.2 KiB | text/x-python | PythonLexer
"""Publishing
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2012 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 import Configurable
from IPython.utils.jsonutil import json_clean
from IPython.utils.traitlets import Instance, Dict, CBytes
from IPython.zmq.serialize import serialize_object
from IPython.zmq.session import Session, extract_header
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
class ZMQDataPublisher(Configurable):
topic = topic = CBytes(b'datapub')
session = Instance(Session)
pub_socket = Instance('zmq.Socket')
parent_header = Dict({})
def set_parent(self, parent):
"""Set the parent for outbound messages."""
self.parent_header = extract_header(parent)
def publish_data(self, data):
"""publish a data_message on the IOPub channel
Parameters
----------
data : dict
The data to be published. Think of it as a namespace.
"""
session = self.session
buffers = serialize_object(data,
buffer_threshold=session.buffer_threshold,
item_threshold=session.item_threshold,
)
content = json_clean(dict(keys=data.keys()))
session.send(self.pub_socket, 'data_message', content=content,
parent=self.parent_header,
buffers=buffers,
ident=self.topic,
)
def publish_data(data):
"""publish a data_message on the IOPub channel
Parameters
----------
data : dict
The data to be published. Think of it as a namespace.
"""
from IPython.zmq.zmqshell import ZMQInteractiveShell
ZMQInteractiveShell.instance().data_pub.publish_data(data)