API

class coralillo.Form[source]

Parent class of the Model class, defines validation and other useful functions.

classmethod validate(**kwargs)[source]

Validates the data received as keyword arguments whose name match this class attributes.

class coralillo.Model(id=None, **kwargs)[source]

Defines a model that comunicates to the Redis database

__eq__(other)[source]

Compares this object to another. Returns true if both are of the same class and have the same properties. Returns false otherwise

classmethod cls_key()[source]

Returns the redis key prefix assigned to this model

classmethod count()[source]

returns object count for this model

delete()[source]

Deletes this model from the database, calling delete in each field to properly delete special cases

fqn()[source]

Returns a fully qualified name for this object

classmethod get(id)[source]

Retrieves an object by id. Returns None in case of failure

classmethod get_all()[source]

Gets all available instances of this model from the database

classmethod get_by(field, value)[source]

Tries to retrieve an isinstance of this model from the database given a value for a defined index. Return None in case of failure

classmethod get_or_exception(id)[source]

Tries to retrieve an instance of this model from the database or raises an exception in case of failure

static is_object_key()[source]

checks if the given key belongs to an object. Its easy since it depends on the key ending like: ‘:obj’

key()[source]

Returns the redis key to access this object’s values

classmethod members_key()[source]

This key holds a set whose members are the ids that exist of objects from this class

permission(restrict=None)[source]

Returns a fully qualified key name to a permission over this object

reload()[source]

reloads this object so if it was updated in the database it now contains the new values

save()[source]

Persists this object to the database. Each field knows how to store itself so we don’t have to worry about it

to_json(fields=None, embed=None)[source]

Serializes this model to a JSON representation so it can be sent via an HTTP REST API

classmethod tree_match(field, string)[source]

Given a tree index, retrieves the ids atached to the given prefix, think of if as a mechanism for pattern suscription, where two models attached to the a, a:b respectively are found by the a:b string, because both model’s subscription key matches the string.

update(**kwargs)[source]

validates the given data against this object’s rules and then updates