pyworkflow.mapper.mapper module

class pyworkflow.mapper.mapper.Mapper(dictClasses=None)[source]

Bases: object

This class will serves as a Data Mapper pattern. It will store/retrieve objects from some storage environment. (like SQL, XML or others) The mapper should have access to class dictionary in order to build any give class by name

ORIGINAL_CLASS_NAME_ATTRIBUTE = 'oldClassName'
static annotateClassName(instance, oldClassName)[source]

Annotate an object with the original class name

commit()[source]

Commit changes made to the storage

deleteRelations(creatorObj)[source]

Delete all relations created by object creatorObj

exists(objId)[source]

Return True if the id is in the database

getFullName(obj)[source]

Return the full object name such as: grandparent.parent.objName

static getObjectPersistingClassName(instance)[source]
getParent(obj)[source]

Retrieve the parent object of another.

getRelationChilds(relName, parentObj)[source]

Return all “child” objects for a given relation. Params:

relName: the name of the relation. parentObj: this is “parent” in the relation

Returns:

a list of “child” objects.

getRelationParents(relName, childObj)[source]

Return all “parent” objects for a given relation. Params:

relName: the name of the relation. childObj: this is “child” in the relation

Returns:

a list of “parent” objects.

getRelationsByCreator(creatorObj)[source]

Return all relations created by creatorObj.

insert(obj)[source]

Insert a new object into the system, the id will be set

insertRelation(relName, creatorObj, parentObj, childObj)[source]

This function will add a new relation between two objects. Params:

relName: the name of the relation to be added. creatorObj: this object will be the one who register the relation. parentObj: this is “parent” in the relation childObj: this is “child” in the relation

selectAll(iterate=False)[source]

Return all object from storage

selectBy(**args)[source]

Select object meetings some criteria

selectByClass(className, includeSubclasses=True)[source]

Select all object of a give class. By default object of subclasses will be retrieved also. This behaviour can be changed by passing includeSubclass=False

selectById(objId)[source]

Return the object which id is objId

selectFirst()[source]

Return only the first element

store(obj)[source]

Stores an object, it can be inserted or updated

update(obj, direction='to')[source]

Update an existing object, the id should not be None direction can be “to” or “from” which indicates the priority of the update. If “to” is used, object data is put in storage. If “from”, object data is retrieved from storage

updateFrom(obj)[source]

Update object data with storage info

updateTo(obj)[source]

Update storage with object info

warning(msg)[source]