Ejemplo n.º 1
0
 def create(cls):
     """Create a new Network node with storage node capabilities"""
     n = nt.Network()
     n.addAttribute(persistence.createStorageAttribute(persistence.PyPickleData.kPluginDataId))
     # add another attribute with a prefix - multiple data attributes should be possible
     n.addAttribute(persistence.createStorageAttribute(persistence.PyPickleData.kPluginDataId, 'a'))
     return StorageNetworkNode(n.object())
Ejemplo n.º 2
0
 def create(cls):
     """Create a new Network node with storage node capabilities"""
     n = nt.Network()
     n.addAttribute(
         persistence.createStorageAttribute(
             persistence.PyPickleData.kPluginDataId))
     return StorageNetworkNode(n.object())
Ejemplo n.º 3
0
    def test_storageAttributeHanlding(self):
        mrvmaya.Scene.new(force=True)
        snode = nt.createNode("storage", "storageNode")

        # autocreate off
        self.failUnlessRaises(AttributeError, snode.pythonData, "test")

        data = snode.masterPlug()
        val = snode.pythonData("test", autoCreate=True)
        oval = snode.pythonData("othertest", autoCreate=True)
        assert not oval.isReferenced()
        assert data.length() == 2
        # have two right now, no prefix
        assert len(snode.dataIDs()) == 2

        # check flags plug
        fplug = snode.storagePlug("test", snode.kFlags)
        assert fplug.asInt() == 0
        fplug.msetInt(5)
        assert fplug.asInt() == 5

        # CLEAR EMPTY DATA
        ######################
        snode.clearData("test")

        # PREFIXES
        ############
        snode.setDataPrefix("prefix")  # must create new one
        pval = snode.pythonData("othertest", autoCreate=True)
        assert data.length() == 3
        assert pval._plug.mparent().mchildByName("id").asString() == "prefixothertest"

        # now that we have a prefix, we only see prefixed attributes
        assert len(snode.dataIDs()) == 1

        # STORAGE PLUGS (MAIN PLUG)
        # contains connection plug too
        mainplug = snode.findStoragePlug("othertest")
        assert mainplug == pval._plug.mparent()

        # attribute prefix
        assert snode.attributePrefix() == ""
        attr_prefix = "attr_prefix_"
        snode.addAttribute(createStorageAttribute(PyPickleData.kPluginDataId, name_prefix=attr_prefix))
        snode.setAttributePrefix(attr_prefix)
        assert snode.masterPlug().length() == 0
        snode.setAttributePrefix("")
        assert snode.masterPlug().length() == data.length()

        # CONNECTION PLUGS
        ###################
        persp = nt.Node("persp")

        conarray = mainplug.mchildByName("dmsg")
        for c in range(10):
            nextplug = conarray.elementByLogicalIndex(c)
            persp.message.mconnectTo(nextplug)
            assert persp.message.misConnectedTo(nextplug)
        assert conarray.length() == 10
        assert len(persp.message.moutputs()) == 10
Ejemplo n.º 4
0
	def create(cls):
		"""Create a new Network node with storage node capabilities"""
		n = nt.Network()
		n.addAttribute(persistence.createStorageAttribute(persistence.PyPickleData.kPluginDataId))
		return StorageNetworkNode(n.object())