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.

__eq__(other)[source]

True if and only if the primary keys are the same

__getitem__(key)[source]

Return either the value of the property or the default value of the property if the real value is undefined

__len__()[source]

The number of keys in the object

__setitem__(key, value)[source]

Set the value of the property, saving it if it is an unsaved Document instance

application[source]

The application instance this document’s collection is attached to.

defaults = {}
definitions = {}
delete(**kwargs)[source]
exposed_methods = {}
fetch(key)[source]

Return the value of the property interpreting it as a reference to another document

help(out=None, initial_heading_level=0)[source]

Return full reStructuredText help for this class

id[source]

The value of the primary key field. None if the value has not yet been saved.

json(*args, **kwargs)[source]
name[source]
processors = []
save(conflict='replace', *args, **kwargs)[source]
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'}
schema_url[source]
slug[source]

Included for symmetry with application and collection, the same as ‘id’.

specials = {}
suite[source]

The suite instance this document’s application is attached to.

template = '{id}'
title = 'Document'
url[source]
validate()[source]
class sondra.document.DocumentMetaclass(name, bases, nmspc)[source]

Bases: abc.ABCMeta

The metaclass for all documents merges definitions and schema into a single schema attribute and makes sure that exposed methods are catalogued.