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

Class StorageBase

source code

         object --+        
                  |        
interface.Interface --+    
                      |    
interface.iDuplicatable --+
                          |
                         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. Additionally you can store connections. Nodes used with this interface must be compatible to the following attribute scheme. To create that scheme, use createStorageAttribute

Attribute Setup:

(shortname (description) [data type])
dta (data)[multi compound]
        id (data id)[string]
        type (data type) [int]  # for your own use, store bitflags to specify attribute
        dval (data value) [python pickle]
        dmsg (data message)[multi message]

Configuration:

data_prefix: will prefix every value name when setting and getting values - this allows
        several clients to use the same storage attribute (on the same node for example)
        It acts like a namespace
attr_prefix: prefixes the actual maya attribute to access
maya_node: the maya node holding the actual attributes

Notes:

To Do: should self._node be stored as weakref ?

Nested Classes [hide private]
  PyPickleValue
Wrapper object prividing native access to the wrapped python pickle object and to the corresponding value plug, providing utlity methods for easier handling
Instance Methods [hide private]
 
storageNode(self)
Returns: Node actually being used as storage
source code
 
setStorageNode(self, node)
Set ourselves to use the given storage compatible node
source code
 
setDataPrefix(self, prefix)
Change the data prefix to the given value string
source code
 
dataPrefix(self)
Returns: our data prefix
source code
 
attributePrefix(self)
Returns: our attribute prefix
source code
 
setAttributePrefix(self, prefix)
Change the prefix with which to access to the actual storage data attributes on our node to the given string
source code

Inherited from interface.iDuplicatable: copyTo, copyToOther, duplicate

Inherited from interface.Interface: supports

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Overridden Methods
 
__init__(self, data_prefix='', maya_node=None, attr_prefix='')
Allows customization of this base to modify its behaviour :note: see more information on the input attributes in the class description
source code
    Edit
 
makePlug(self, dataID)
see makePlug module level function
source code
 
clearAllData(self)
see ``clearAllData`` module level method...
source code
 
clearData(self, dataID)
Clear all data stored in the given dataID
source code
    Query Plugs
 
_elementPlug(self, dataID, dataType, autoCreate=False)
Returns: element plug of the given type
source code
 
findStoragePlug(self, dataID)
Returns: compound plug with given dataID or None
source code
 
masterPlug(self)
Returns: master plug according to our attributePrefix
source code
 
dataIDs(self)
see module level function with the same name
source code
 
storagePlug(self, dataID, plugType=None, autoCreate=False)
see storagePlug module level function
source code
    Query Data
 
pythonData(self, dataID, **kwargs)
Returns: PyPickleVal object at the given index (it can be modified natively)
source code
    Set Handling
 
objectSet(self, dataID, setIndex, autoCreate=True)
see module level objectSet function
source code
 
deleteObjectSet(self, dataID, setIndex)
See the module level method called deleteObjectSet
source code
 
setsByID(self, dataID)
Returns: all object sets stored under the given dataID
source code
 
setPartition(self, dataID, state)
see setPartition function on module level
source code
 
partition(self, dataID)
Returns: partition Node attached to the sets at dataID or None if state is disabled
source code
    Interface
 
createInstance(self, *args, **kwargs)
Create a new instance with our type
source code
 
copyFrom(self, other, *args, **kwargs)
Copy all values from other to ourselves
source code
Class Methods [hide private]
    Query Data
 
pythonDataFromPlug(cls, valplug)
Exract the python data using the given plug directly
source code
Class Variables [hide private]
  kPartitionIdAttr = "bda_storagePartition"
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, data_prefix='', maya_node=None, attr_prefix='')
(Constructor)

source code 
Allows customization of this base to modify its behaviour :note: see more information on the input attributes in the class description
Overrides: object.__init__

createInstance(self, *args, **kwargs)

source code 
Create a new instance with our type
Returns:
new instance of self
Overrides: interface.iDuplicatable.createInstance

copyFrom(self, other, *args, **kwargs)

source code 
Copy all values from other to ourselves
Parameters:
  • kwargs -
    • shallow:

      if True, default False, only a shallow copy will be made. If False, a deep copy will be made

Overrides: interface.iDuplicatable.copyFrom
Notes:
  • only does so if the attribute and data prefixes actually match (which should be the case if we get here, checking for it anyway
  • as pickle data always copies by reference to be efficient, we have to explicitly create new data to assure we really copy it

To Do: copy connections to our messages as well, make it an option at least

clearAllData(self)

source code 
see ``clearAllData`` module level method
:note: use this method if you want to make sure your node
        is empty after it has been duplicated (would usually be done in the postContructor

Decorators:
  • @undoable

clearData(self, dataID)

source code 
Clear all data stored in the given dataID
Decorators:
  • @undoable

_elementPlug(self, dataID, dataType, autoCreate=False)

source code 
Returns:
element plug of the given type

findStoragePlug(self, dataID)

source code 
Returns:
compound plug with given dataID or None

masterPlug(self)

source code 
Returns:
master plug according to our attributePrefix

pythonData(self, dataID, **kwargs)

source code 
Parameters:
  • dataID - id of of the data to retrieve
  • kwargs -
    • index:

      element number of the plug to retrieve, or -1 to get a new plug. Plugs will always be created, the given index specifies a logical plug index

    • Additionally all arguments supported by storagePlug

Returns:
PyPickleVal object at the given index (it can be modified natively)

pythonDataFromPlug(cls, valplug)
Class Method

source code 
Exract the python data using the given plug directly
Parameters:
  • valplug - data value plug containing the plugin data
Returns:
PyPickleData object allowing data access

objectSet(self, dataID, setIndex, autoCreate=True)

source code 
see module level objectSet function
Decorators:
  • @undoable

deleteObjectSet(self, dataID, setIndex)

source code 
See the module level method called deleteObjectSet
Decorators:
  • @undoable

setsByID(self, dataID)

source code 
Returns:
all object sets stored under the given dataID

setPartition(self, dataID, state)

source code 
see setPartition function on module level
Decorators:
  • @undoable

partition(self, dataID)

source code 
Returns:
partition Node attached to the sets at dataID or None if state is disabled

storageNode(self)

source code 
Returns:
Node actually being used as storage

setStorageNode(self, node)

source code 
Set ourselves to use the given storage compatible node

Note: use this if the path of our instance has changed - otherwise trying to access functions will fail as the path of our node might be invalid

dataPrefix(self)

source code 
Returns:
our data prefix

attributePrefix(self)

source code 
Returns:
our attribute prefix