tori.db.common

Author:Juti Noppornpitak <jnopporn@shiroyuki.com>
Stability:Stable
class tori.db.common.ProxyCollection(session, origin, guide)

Proxy Collection

This collection is extended from the built-in class list, designed to only load the associated data whenever is required.

Parameters:

Note

To replace with criteria and driver

reload()

Reload the data list

Warning

This method is not recommended to be called directly. Use tori.db.session.Session.refresh() on the owned object instead.

class tori.db.common.ProxyFactory

Proxy Factory

This factory is to create a proxy object.

Parameters:
class tori.db.common.ProxyObject(session, cls, object_id, read_only, cascading_options, is_reverse_proxy)

Proxy Collection

This class is designed to only load the entity whenever the data access is required.

Parameters:
  • session (tori.db.session.Session) – the managed session
  • cls (type) – the class to map the data
  • object_id – the object ID
  • read_only (bool) – the read-only flag
  • cascading_options (list or tuple) – the cascading options
  • is_reverse_proxy (bool) – the reverse proxy flag
class tori.db.common.PseudoObjectId(oid=None)

Pseudo Object ID

This class extends from bson.objectid.ObjectId.

This is used to differentiate stored entities and new entities.

class tori.db.common.Serializer(max_depth=2, mode='forgiven')

Object Serializer for Entity

encode(data, stack_depth=0, convert_object_id_to_str=False)

Encode data into dictionary and list.

Parameters:
  • data – the data to encode
  • stack_depth – traversal depth limit
  • convert_object_id_to_str – flag to convert object ID into string