API Docs

User-level API.

class invenio_sequencegenerator.api.Sequence(template, **kwargs)[source]

Iterator for sequences.

Initialize.

Parameters:
  • template – The template that this sequence is based on.
  • **kwargs – The kwargs to instantiate the template.
counter[source]

Cache internal counter.

next()[source]

Get next identifier.

class invenio_sequencegenerator.api.Template(name, _model=None)[source]

API for defining sequences.

Initialize template.

Parameters:
  • name – The identifier of the template.
  • _model – The model object of the template.
classmethod create(name, meta_template, start=0, step=1)[source]

Create a new sequence definition.

Parameters:
  • name – The identifier of the template definition.
  • meta_template – The template generator.
  • start – The starting counter of sequences based on this template.
  • step – The incremental step of sequences based on this template.

Models

Models for storing counters for each pattern.

class invenio_sequencegenerator.models.Counter(**kwargs)[source]

Stores generated identifiers.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

counter

Running counter.

classmethod create(meta_template, ctx=None, **kwargs)[source]

Initialize a counter.

definition_name

Link to the template definition.

classmethod get(definition, ctx=None)[source]

Get a Counter.

increment()[source]

Generate next identifier.

reset(start=0)[source]

Reset counter.

template_instance

The template string to use.

class invenio_sequencegenerator.models.TemplateDefinition(**kwargs)[source]

Representation of a template definition.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

COUNTER_REGEX = <_sre.SRE_Pattern object>

Regular expression matching the counter inside the template string.

counter(**kwargs)[source]

Get counter of this template definition, based on given kwargs.

meta_template

The template generator.

name

The identifier of the template definition.

parent_name

Indicate that the template depends on another one.

start

The starting counter of sequences generated from meta_template.

step

The incremental step of sequences generated from meta_template.

validate_meta_template(key, value)[source]

Validate template string of template definition.

invenio_sequencegenerator.models.derive_parent(target, value, oldvalue, initiator)[source]

Automatically derive parent from template string.