Package mrv :: Package maya :: Package nt :: Module storage
[hide private]
[frames] | no frames]

Module storage

source code

Contains an implementation for the Persistence plugin for easy access within mrv and derived nodes.
Classes [hide private]
    Storage Access
  StorageBase
A storage node contains a set of attributes allowing it to store python data and objects being stored in a pickled format upon file save.
  StorageNode
This node can be used as pythonic and easy-to-access value container - it could be connected to your node, and queried for values actually being queried on your node.
Functions [hide private]
    Procedural Access
 
findStoragePlug(masterPlug, dataID)
Returns: compound plug containing all data and connections for the given dataID
source code
 
_makeElementPlug(masterPlug, dataID)
Find an empty logical plug index and return the newly created logical plug with given dataID - unconditionally
source code
 
storagePlug(masterPlug, dataID, plugType=None, autoCreate=False)
Returns: plug of the given type, either as tuple of two plugs or the plug specified by plugType
source code
 
makePlug(masterPlug, dataID)
retrieve or create a plug that corresponds to the given dataID...
source code
 
setsByPlug(mdplug)
Returns: all objectSets stored at the given message data plug
source code
 
partition(mdplug)
Returns: parition node attached to the sets of the given message data plug or None
source code
 
objectSet(mdplug, setIndex, autoCreate=True, setPrefix='')
Get an object set identified with setIndex at the given dataId
source code
 
dataIDs(masterPlug, data_prefix='')
Returns: list of all data ids available in the given master plug
source code
 
setPartition(mdplug, state)
Make all sets of the given data message plug use a partition or not :param state: if True, a partition will be used, if False, it will be disabled :note: this method makes sure that all sets are hooked up to the partition :raise ValueError: If we did not have a single set to which to add to the partition :raise AttributeError: If the dataID has never had sets :return: if state is True, the name of the possibly created (or existing) partition
source code
 
clearDataPlug(vdplug)
Clear the data in the given value data plug
source code
 
clearAllData(masterPlug)
Empty all data storage plugs beneath the given masterPlug.
source code
 
deleteObjectSet(mdplug, setIndex)
Delete the object set at the given message data plug, at the given setIndex...
source code
Variables [hide private]
  MFnDependencyNode = api.MFnDependencyNode
Function Details [hide private]

findStoragePlug(masterPlug, dataID)

source code 
Parameters:
  • masterPlug - compound plug containing all data
Returns:
compound plug containing all data and connections for the given dataID

_makeElementPlug(masterPlug, dataID)

source code 
Find an empty logical plug index and return the newly created logical plug with given dataID - unconditionally
Decorators:
  • @undoable

storagePlug(masterPlug, dataID, plugType=None, autoCreate=False)

source code 
Parameters:
  • masterPlug - masterPlug to search for data
  • dataID - the name of the plug to be returned
  • plugType - StorageBase.kMessage: return message array plug only StorageBase.kValue: return python pickle array plug only StorageBase.kStorage: return the storage plug itself containing message and the value plug StorageBase.kFlags return plug to integer which can be used as storage for bitflags to accompany the id None: return (picklePlug , messagePlug)
  • autoCreate - if True, a plug with the given dataID will be created if it does not yet exist
Returns:
plug of the given type, either as tuple of two plugs or the plug specified by plugType
Decorators:
  • @undoable
Raises:
  • AttributeError - if a plug with dataID does not exist and default value is None
  • TypeError - if plugtype unknown

makePlug(masterPlug, dataID)

source code 
retrieve or create a plug that corresponds to the given dataID
:param dataID: string identifier
:return: the created data plug, containing subplugs dval and dmsg
        for generic data and  message connections respectively 

Decorators:
  • @undoable

setsByPlug(mdplug)

source code 
Returns:
all objectSets stored at the given message data plug

partition(mdplug)

source code 
Returns:
parition node attached to the sets of the given message data plug or None

objectSet(mdplug, setIndex, autoCreate=True, setPrefix='')

source code 
Get an object set identified with setIndex at the given dataId
Parameters:
  • mdplug - data message plug whose object set to handle
  • setIndex - logical index at which the set will be connected to our message plug array
  • autoCreate - if True, a set will be created if it does not yet exist
  • setPrefix - if given, the string will be used as prefix for the name of newly created object sets
Decorators:
  • @undoable
Raises:
  • ValueError - if a set does not exist at setIndex and autoCreate is False
  • AttributeError - if the plug did not exist (and autocreate is False)
Notes:
  • method is implicitly undoable if autoCreate is True, this also means that you cannot explicitly undo this operation as you do not know if undo has been queued or not
  • newly created sets will automatically use partitions if one of the sets does

dataIDs(masterPlug, data_prefix='')

source code 
Parameters:
  • data_prefix - the string prefix of data names which must match with the prefix of the data id to be returned, with the matching prefix pruned. By default, all data ids will match
Returns:
list of all data ids available in the given master plug

setPartition(mdplug, state)

source code 
Make all sets of the given data message plug use a partition or not :param state: if True, a partition will be used, if False, it will be disabled :note: this method makes sure that all sets are hooked up to the partition :raise ValueError: If we did not have a single set to which to add to the partition :raise AttributeError: If the dataID has never had sets :return: if state is True, the name of the possibly created (or existing) partition
Decorators:
  • @undoable

clearAllData(masterPlug)

source code 
Empty all data storage plugs beneath the given masterPlug. Message connections are currently not affected
Decorators:
  • @undoable

deleteObjectSet(mdplug, setIndex)

source code 
Delete the object set at the given message data plug, at the given setIndex
:note: use this method to delete your sets instead of manual deletion as it will automatically
        remove the managed partition in case the last set is being deleted

Decorators:
  • @undoable