Skip to content

Pylib bcp.connection

campadrenalin edited this page Sep 22, 2011 · 1 revision

ConcurrenTree.model.bcp.connection

BCPConnection

The name pretty much says it all. This is a connection that handles BCP. IO input goes is processed by a chain of functions: incoming >> recv >> analyze. Incoming separates messages by nullbytes and handles the buffer, recv turns textual messages into dicts and checks that they have a "type" value, and analyze is a big monstrous function that applies the message.

Methods:
* __init__(docs, auth) # initializes with the given docs and auth objects. Auth is not used yet.
* incoming(value) # analyzes buffer, extracts at most one message, and returns the resulting buffer.
* outgoing(msg) # forwards a pool message to IO.
* recv(msg) # Attempts to parse raw string message, then call analyze on it.
* push(msgtype, **kwargs) # Send a message with type msgtype, and properties kwargs. Calls self.send(msg).
* send(msg) # Sends a message to IO.
* select(docname) # Selects document "docname" locally.
* analyze(obj, objstring) # Takes a BCP message and tries to apply it.
* check_selected(is_loaded=True) # Checks that the remote end has selected a docname, and we have that doc.
* require(arg, obj) # Raises an exception if arg is not in obj. Used extensively in analyze.
* error(num=500, details="", data=None) # Sends an error message to the remote end.

Properties:
* docs # a dictlike object containing documents keyed on docname.
* auth # Not used yet.
* here # bcp.peer representing local end.
* there # bcp.peer representing remote end.
* fdoc # Document currently selected by remote end (foreign doc).
* ldoc # Document currently selected by local end (local doc).

Pylib BCP
Python Library

Clone this wiki locally