entity

This module provides the camelot.core.orm.entity.EntityBase declarative base class, as well as its metaclass camelot.core.orm.entity.EntityMeta. Those are the building blocks for creating the camelot.core.orm.Entity.

These classes can be reused if a custom base class is needed.

class camelot.core.orm.entity.EntityBase(*args, **kwargs)[source]

A declarative base class that adds some methods that used to be available in Elixir

from_dict(data)[source]

Update a mapped class with data from a JSON-style nested dict/list structure.

classmethod get(*args, **kwargs)[source]

Return the instance of this class based on the given identifier, or None if not found. This is equivalent to: session.query(MyClass).get(...)

classmethod get_by(*args, **kwargs)[source]

Returns the first instance of this class matching the given criteria. This is equivalent to: session.query(MyClass).filter_by(...).first()

to_dict(deep={}, exclude=[])[source]

Generate a JSON-style nested dict/list structure from an object.

class camelot.core.orm.entity.EntityDescriptor(entity_base)[source]

EntityDescriptor holds information about the Entity before it is passed to Declarative. It is used to search for inverse relations defined on an Entity before the relation is passed to Declarative.

Parameters:entity_base – The Declarative base class used to subclass the entity
create_pk_cols()[source]

Create primary_key columns. That is, call the ‘create_pk_cols’ builders then add a primary key to the table if it hasn’t already got one and needs one.

This method is “semi-recursive” in some cases: it calls the create_keys method on ManyToOne relationships and those in turn call create_pk_cols on their target. It shouldn’t be possible to have an infinite loop since a loop of primary_keys is not a valid situation.

get_inverse_relation(rel, check_reverse=True)[source]

Return the inverse relation of rel, if any, None otherwise.

class camelot.core.orm.entity.EntityMeta(classname, bases, dict_)[source]

Subclass of sqlalchmey.ext.declarative.DeclarativeMeta. This metaclass processes the Property and ClassMutator objects.

camelot.core.orm.entity.dict_to_entity(entity, data)[source]

Update a mapped object with data from a JSON-style nested dict/list structure.

Parameters:
  • entity – the Entity object into which to store the data
  • data – a dict with data to store into the entity
camelot.core.orm.entity.entity_to_dict(entity, deep={}, exclude=[])[source]

Generate a JSON-style nested dict/list structure from an object.

Previous topic

orm

Next topic

fields

This Page