tree_handler module

This module provides database for Tree instances.

class storage.tree_handler.TreeHandler(conf_path='/home/docs/checkouts/readthedocs.org/user_builds/edeposit-amqp-storage/checkouts/latest/src/edeposit/amqp/storage/zconf/zeo_client.conf', project_key='tree_storage')

This class is used as database handler for Tree instances.

name_db_key

str – Key for the name_db.

name_db

dict – Database handler dict for name.

aleph_id_db_key

str – Key for the aleph_id_db.

aleph_id_db

dict – Database handler dict for aleph_id.

issn_db_key

str – Key for the issn_db.

issn_db

dict – Database handler dict for issn.

path_db_key

str – Key for the path_db.

path_db

dict – Database handler dict for path.

parent_db_key

str – Key for the parent_db.

parent_db

dict – Database handler dict for parent.

Constructor.

Parameters:
add_tree(*args, **kwargs)

Add tree into database.

Parameters:
  • tree (obj) – Tree instance.
  • parent (ref, default None) – Reference to parent tree. This is used for all sub-trees in recursive call.
remove_tree_by_path(path)

Remove the tree from database by given path.

Parameters:path (str) – Path of the tree.
remove_tree(tree)

Remove the tree from database using tree object to identfy the path.

Parameters:tree (obj) – Tree instance.
trees_by_issn(*args, **kwargs)

Search trees by issn.

Parameters:issn (str) – Tree.issn property of Tree.
Returns:Set of matching Tree instances.
Return type:set
trees_by_path(*args, **kwargs)

Search trees by path.

Parameters:path (str) – Tree.path property of Tree.
Returns:Set of matching Tree instances.
Return type:set
trees_by_subpath(*args, **kwargs)

Search trees by sub_path using Tree.path.startswith(sub_path) comparison.

Parameters:sub_path (str) – Part of the Tree.path property of Tree.
Returns:Set of matching Tree instances.
Return type:set
get_parent(*args, **kwargs)

Get parent for given tree or alt if not found.

Parameters:
  • tree (obj) – Tree instance, which is already stored in DB.
  • alt (obj, default None) – Alternative value returned when tree is not found.
Returns:

Tree parent to given tree.

Return type:

obj

storage.tree_handler.tree_handler(*args, **kwargs)

Singleton TreeHandler generator. Any arguments are given to TreeHandler, when it is first created.

Returns:TreeHandler instance.
Return type:obj