Note
This documentation is for a development version of IPython. There may be significant differences from the latest stable release (1.2.1).
Session object for building, serializing, sending, and receiving messages in IPython. The Session object supports serialization, HMAC signatures, and metadata on messages.
Also defined here are utilities for working with Sessions: * A SessionFactory to be used as a base class for configurables that work with Sessions. * A Message object for convenience that allows attribute-access to the msg dict.
Authors:
Bases: IPython.config.configurable.LoggingConfigurable
The Base class for configurables that have a Session, Context, logger, and IOLoop.
Bases: object
A simple message object that maps dict keys to attributes.
A Message can be created from a dict and a dict from a Message instance simply by calling dict(msg_obj).
Bases: IPython.config.configurable.Configurable
Object for handling serialization and sending of messages.
The Session object handles building messages and sending them with ZMQ sockets or ZMQStream objects. Objects can communicate with each other over the network via Session objects, and only need to work with the dict-based IPython message spec. The Session will handle serialization/deserialization, security, and metadata.
Sessions support configurable serialiization via packer/unpacker traits, and signing with HMAC digests via the key/keyfile traits.
Parameters: | debug : bool
packer/unpacker : str
pack/unpack : callables
session : bytes
username : unicode
key : bytes
keyfile : filepath
|
---|
create a Session object
Parameters: | debug : bool
packer/unpacker : str
pack/unpack : callables
session : unicode (must be ascii)
bsession : bytes
username : unicode
key : bytes
signature_scheme : str
keyfile : filepath
|
---|
Split the identities from the rest of the message.
Feed until DELIM is reached, then return the prefix as idents and remainder as msg_list. This is easily broken by setting an IDENT to DELIM, but that would be silly.
Parameters: | msg_list : a list of Message or bytes objects
copy : bool
|
---|---|
Returns: | (idents, msg_list) : two lists
|
Return the nested message dict.
This format is different from what is sent over the wire. The serialize/unserialize methods converts this nested message dict to the wire format, which is a list of message parts.
always return new uuid
Receive and unpack a message.
Parameters: | socket : ZMQStream or Socket
|
---|---|
Returns: | [idents], msg
|
Build and send a message via stream or socket.
The message format used by this function internally is as follows:
The serialize/unserialize methods convert the nested message dict into this format.
Parameters: | stream : zmq.Socket or ZMQStream
msg_or_type : str or Message/dict
content : dict or None
header : dict or None
parent : Message or dict or None
ident : bytes or list of bytes
metadata : dict or None
buffers : list or None
track : bool
|
---|---|
Returns: | msg : dict
|
Send a raw message via ident path.
This method is used to send a already serialized message.
Parameters: | stream : ZMQStream or Socket
msg_list : list
ident : ident or list
|
---|
Serialize the message components to bytes.
This is roughly the inverse of unserialize. The serialize/unserialize methods work with full message lists, whereas pack/unpack work with the individual message parts in the message list.
Parameters: | msg : dict or Message
|
---|---|
Returns: | msg_list : list
|
Sign a message with HMAC digest. If no auth, return b’‘.
Parameters: | msg_list : list
|
---|
Unserialize a msg_list to a nested message dict.
This is roughly the inverse of serialize. The serialize/unserialize methods work with full message lists, whereas pack/unpack work with the individual message parts in the message list.
Parameters: | msg_list : list of bytes or Message objects
content : bool (True)
copy : bool (True)
|
---|---|
Returns: | msg : dict
|
coerce unicode back to bytestrings.
Set the default behavior for a config environment to be secure.
If Session.key/keyfile have not been set, set Session.key to a new random UUID.
Given a message or header, return the header.