passerine.db.mapper

Note

This page is automatically generated. If you don’t see anything, this means this sub-module is not meant to be used. If you really want to know what it is, please check out the source code at passerine/db/mapper.py.

Note

The current implementation doesn’t support merging or detaching a document simultaneously observed by at least two entity manager.

class passerine.db.mapper.AssociationFactory(origin, guide, cascading_options, is_reverse_mapping)

Association Factory

class_name

Auto-generated Association Class Name

Return type:str

Note

This is a read-only property.

cls

Auto-generated Association Class

Return type:type

Note

This is a read-only property.

collection_name

Auto-generated Collection Name

Return type:str

Note

This is a read-only property.

destination

Destination

Return type:type
origin

Origin

Return type:type
class passerine.db.mapper.AssociationType

Association Type

AUTO_DETECT = 1

Auto detection (default, disabled and raising exception)

MANY_TO_MANY = 5

Many-to-many association mode

MANY_TO_ONE = 4

Many-to-one association mode

ONE_TO_MANY = 3

One-to-many association mode

ONE_TO_ONE = 2

One-to-one association mode

static known_type(t)

Check if it is a known type

Parameters:t (int) – type
Returns:True if it is a known type.
Return type:bool
class passerine.db.mapper.BasicGuide(target_class, association)

Basic Relation Guide

This class is abstract and used with the relational map of the given entity class.

Parameters:
  • target_class (object) – the target class or class name (e.g., acme.entity.User)
  • association (int) – the type of association
target_class

The target class

Return type:type
class passerine.db.mapper.CascadingType

Cascading Type

DELETE = 2

Cascade on delete operation

DETACH = 4

Cascade on detach operation

Note

Supported in Tori 2.2

MERGE = 3

Cascade on merge operation

Note

Supported in Tori 2.2

PERSIST = 1

Cascade on persist operation

REFRESH = 5

Cascade on refresh operation

class passerine.db.mapper.RelatingGuide(entity_class, target_class, inverted_by, association, read_only, cascading_options)

Relation Guide

This class is used with the relational map of the given entity class.

Parameters:
  • entity_class (type) – the reference of the current class
  • mapped_by (str) – the name of property of the current class
  • target_class (type) – the target class or class name (e.g., acme.entity.User)
  • inverted_by (str) – the name of property of the target class
  • association (int) – the type of association
  • read_only (bool) – the flag to indicate whether this is for read only.
  • cascading_options (list or tuple) – the list of actions on cascading

Association decorator

New in version 2.1.

This is to map a property of the current class to the target class.

Parameters:
  • mapped_by (str) – the name of property of the current class
  • target (type) – the target class or class name (e.g., acme.entity.User)
  • inverted_by (str) – the name of property of the target class
  • association (int) – the type of association
  • read_only (bool) – the flag to indicate whether this is for read only.
  • cascading (list or tuple) – the list of actions on cascading
Returns:

the decorated class

Return type:

type

Tip

If target is not defined, the default target will be the reference class.

passerine.db.mapper.map(cls, mapped_by=None, target=None, inverted_by=None, association=1, read_only=False, cascading=[])

Map the given class property to the target class.

New in version 2.1.

Parameters:
  • cls (type) – the reference of the current class
  • mapped_by (str) – the name of property of the current class
  • target (type) – the target class or class name (e.g., acme.entity.User)
  • inverted_by (str) – the name of property of the target class
  • association (int) – the type of association
  • read_only (bool) – the flag to indicate whether this is for read only.
  • cascading (list or tuple) – the list of actions on cascading