sondra.document package¶
Module contents¶
Core data document types.
- class sondra.document.Document(obj, collection=None, from_db=False)[source]¶
Bases: collections.abc.MutableMapping
The base type of an individual RethinkDB record.
Each record is an instance of exactly one document class. To combine schemas and object definitions, you can use Python inheritance normally. Inherit from multiple Document classes to create one Document class whose schema and definitions are combined by reference.
Most Document subclasses will define at the very least a docstring,
- collection¶
sondra.collection.Collection – The collection this document belongs to. FIXME could also use URL.
- defaults¶
dict – The list of default values for this document’s properties.
- title¶
str – The title of the document schema. Defaults to the case-split name of the class.
- template¶
string – A template string for formatting documents for rendering. Can be markdown.
- schema¶
dict – A JSON-serializable object that is the JSON schema of the document.
- definitions¶
dict – A JSON-serializable object that holds the schemas of all referenced object subtypes.
- exposed_methods¶
list – A list of method slugs of all the exposed methods in the document.
- __getitem__(key)[source]¶
Return either the value of the property or the default value of the property if the real value is undefined
- __setitem__(key, value)[source]¶
Set the value of the property, saving it if it is an unsaved Document instance
- defaults = {}
- definitions = {}
- exposed_methods = {}
- fetch(key)[source]¶
Return the value of the property interpreting it as a reference to another document
- processors = []¶
- schema = {'properties': {}, 'description': "\n The base type of an individual RethinkDB record.\n\n Each record is an instance of exactly one document class. To combine schemas and object definitions, you can use\n Python inheritance normally. Inherit from multiple Document classes to create one Document class whose schema and\n definitions are combined by reference.\n\n Most Document subclasses will define at the very least a docstring,\n\n Attributes:\n collection (sondra.collection.Collection): The collection this document belongs to. FIXME could also use URL.\n defaults (dict): The list of default values for this document's properties.\n title (str): The title of the document schema. Defaults to the case-split name of the class.\n template (string): A template string for formatting documents for rendering. Can be markdown.\n schema (dict): A JSON-serializable object that is the JSON schema of the document.\n definitions (dict): A JSON-serializable object that holds the schemas of all referenced object subtypes.\n exposed_methods (list): A list of method slugs of all the exposed methods in the document.\n ", 'methods': [], 'template': '{id}', 'definitions': {}, 'type': 'object', 'title': 'Document'}
- specials = {}¶
- template = '{id}'
- title = 'Document'