Skip to content
campadrenalin edited this page Feb 15, 2012 · 1 revision

ConcurrenTree.model.document

Document

A subclass of ConcurrenTree.model.ModelBase, which provides the function __str__ and the property hash, which are a strict string of the protocol representation and the checksum of the protocol representation, respectively.

This class represents the top-level node in a CTree document. It tracks applied ops, and serializes as [concentrate, applied] where applied is a list of op hashes, and concentrate is a "condensed" op that directly takes you from an empty root node to the state of the tree at the time of serialization. This allows you to easily reconstitute a document from storage later, including the list of previously applied ops.

Methods:
* __init__(root, applied=[]) # accepts any Python object valid to node.make()
* apply(op, track=True) # Apply an op, and by default add the op has to the "applied" list
* load(json) # Reconstitute a serialization string into the original document
* flatten() # Flat value of document
* proto() # Return protocol representation (list)

Properties:
* applylist # List of all tracked op hashes

Python Library

Clone this wiki locally