DAO

This is for objects that are meant to represent a database entry, and are lazily loadable.

It’s constructor expects identifier and a keyword argument of load_lazy, which will control when will the object be fetched from DB.

If True, then it will be fetched at constructor time, ie. the constructor will call .refresh(). If False, then it will be fetched when it is first requested, via must_be_loaded decorator.

class satella.dao.Loadable(load_lazy: bool = False)

Any class that can be loaded lazily.

It’s keyword argument, load_lazy is expected to control lazy loading. If set to True, DB will be hit as a part of this object’s constructor.

If False, you will need to load it on-demand via must_be_loaded() decorator.

abstract refresh(load_from=None) None

Ask the database about this object, or load it from provided serialized representation.

Override me, calling me in a super method.

Parameters:

load_from – serialized object. If not given, the DB will be asked for it

satella.dao.must_be_loaded(fun)

A decorator for Loadable’s methods.

Assures that refresh() is called prior to executing that method, ie. the object is loaded from the DB.