Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.utils.instantiator

Defines the Instantiator class and some other utilities used for generating database objects in python fixtures.

Functions

create(model, **kw)

Instantiate, full_clean, save and return a database object.

create_and_get(model, **kw)

Create and then read back from database (the latter to avoid certain Django side effects)

create_or_update_row(model, lookup_values, ...)

Update a single existing row that can be found using param: lookup values, with new_values.

create_row(model, **kw)

Instantiate, full_clean, save and return a database object.

make_if_needed(model, **values)

Classes

InstanceGenerator()

Usage example see lino_xl.lib.humanlinks.fixtures.

Instantiator(model[, fieldnames, ...])

A utility class to make python fixtures more compact.

class lino.utils.instantiator.Instantiator(model, fieldnames=None, converter_classes={}, **kw)

Bases: object

A utility class to make python fixtures more compact. See The Instantiator class.

An instantiator is a

build(*values, **kw)

Instantiate an object using the default values of this instantiator, overridden by the given specified values. The number of positional arguments may not exceed the number of fieldnames specified when creating this Instantiator.

class lino.utils.instantiator.InstanceGenerator

Bases: object

Usage example see lino_xl.lib.humanlinks.fixtures.

lino.utils.instantiator.create_row(model, **kw)

Instantiate, full_clean, save and return a database object.

lino.utils.instantiator.create_or_update_row(model, lookup_values, new_values)

Update a single existing row that can be found using param: lookup values, with new_values. If one doesn’t exist, instantiates, full_cleans, saves and returns a database object

lino.utils.instantiator.create(model, **kw)

Instantiate, full_clean, save and return a database object.

lino.utils.instantiator.create_and_get(model, **kw)

Create and then read back from database (the latter to avoid certain Django side effects)