FCSXMLObject represents a Final Cut Server entity which uses Final Cut Server Read XML and Write XML watcher+response systems for RPC. This object can only perform a small subset of the tasks that fcsxml.FCSVRClient can perform.
Parameters: |
|
---|
This method will add a new FCSXMLField to the objects field definition list. This function will raise an FCSDuplicate exception if a field object with same name already exists.
Parameters: | field (fcsxml.FCSXMLField) – Provide an FCSXMLField object loaded with field name and value |
---|---|
Returns: | (bool) True or False |
Raises : | fcsxml.FCSDuplicateError, RuntimeError |
Appends a value to field, concatenating with the current field value.
Parameters: |
|
---|---|
Raises : | fcsxml.FCSFieldNotFoundError |
This method returns the datatype for the passed field name.
Parameters: | fieldName (str) – Provide the name of the field to query. |
---|---|
Raises : | fcsxml.FCSFieldNotFoundError |
Returns: | (str) Datatype for the specified field |
This method returns the fcsxml.FCSXMLField object for the passed field name.
Parameters: | fieldName (str) – Provide the name of the field to query. |
---|---|
Raises : | fcsxml.FCSFieldNotFoundError |
Returns: | (fcsxml.FCSXMLField) – The stored field object for the specified field |
This function accepts a list of xml.dom.minidom nodes and will return a collated text string comprised of each nodes value.
Parameters: | nodes (list) – |
---|---|
Returns: | (str) – Concatenated string of all passed nodes’ text values. |
This method will load internal parameters as specified in the provided ConfigParser.SafeConfigParser object, or via the configuration file referenced via the filePath parameter.
Parameters: |
|
---|
Note
If you subclass, you should call this parent function. If we raise a RuntimeError Exception, you should abort or perform your own exhaustive sanity checks
This function will load our object based upon values stored in the provided FCSVRClient object, this is limited to entityID, entityType and defined fields.
Parameters: | fcsvrClient (fcsxml.FCSVRClient) – Provide a loaded FCSVRClient object |
---|---|
Raises : | FCSObjectLoadError |
This function will load the object based upon values present in the XML file found at the provided filepath.
Parameters: | filePath (str) – The path to the XML file to load. |
---|---|
Returns: | (bool) True or False |
Method which loads our object based upon our stored xml.dom.minidom object, which is loaded by fcsxml.FCSXMLObject.loadFromFile() or :func: fcsxml.FCSXMLObject.loadXMLFromString
Parameters: | xml (xml.dom.minidom) – Provide an XML dom.minidom object for which to load from. |
---|---|
Raises : | FCSObjectLoadError |
Returns: | (bool) True |
This method allows our object to load based on the provided XML string. This method utilizes fcsxml.FCSXMLObject.loadXML() to initiate the object.
Parameters: | xmlString (str) – Provide a string of XML data. |
---|---|
Raises : | See mindom.parseString() |
Remove FCSXMLField object registered with passed field name.
Parameters: | fieldName (str or fcsxml.FCSXMLField) – Provide the field name (or an FCSXMLField object) to be removed from the current object’s field list. |
---|---|
Raises : | fcsxml.FCSFieldNotFoundError, RuntimeError |
This method register’s the provided FCSXMLField object, replacing existing field object with same name if it should exist.
Parameters: | field (fcsxml.FCSXMLField) – Provide an FCSXMLField object loaded with field name and value |
---|---|
Returns: | (bool) True or False |
This is a wrapper function for xmlOut, it is included to maintain compatability with the fcsxml.FCSVRClient class interface.
The following section illustrates some example uses of FCSXMLObject.
Import the fcsxml module and instantiate an asset at entity path /asset/22:
## Import our module
>>> import fcsxml
## Create our FCSXMLObject and load our config
>>> myFCSXMLAsset = fcsxml.FCSXMLObject(id=22,entityType='asset')
>>> myFCSXMLAsset.loadConfiguration(filePath='/usr/local/etc/transmogrifier.conf')
True
Because our FCSXMLObject interacts solely with XML files, we are fairly limited with what we can do. In this case, wa have started with an empty object, so all that we can do is to write a field back to FCS. In this example, we will set the value of field Export to FM to True:
## Generate our field object.
>>> myField = fcsxml.FCSXMLField(name='Export to FM',value=True,dataType='bool')
## Associate the new field object to our asset
>>> myFCSXMLAsset.setField(myField)
## Commit the field to FCS
>>> myFCSXMLAsset.setMD()
The setMD function will write out an XML file, in this case containing only an entry for the Export to FM field, to our fcsvr_xmlin directory. By default, this will be the directory named fcsvr_xmlin residing directly inside our support folder as defined by the path variable in our configuraiton file.
A separate usage of fcsxml.FCSXMLObject will be related around ingesting and interpretting XML as provided by an FCS WriteXML response. This is achieved with the function fcsxml.FCSXMLObject.loadFromFile(), as shown below.
## Import our module
>>> import fcsxml
## Create our empty asset, load in the configuration
>>> myFCSXMLAsset = fcsxml.FCSXMLObject(configParser='/usr/local/etc/transmogrifier.conf')
## Read in our XML file
>>> myFCSXMLAsset.loadFromFile('/FCSSupport/fcsvr_xmlout/asset_10.xml')
## Read in a field value
>>> myFCSXMLAsset.valueForField('Title')
u('My Asset Title')
## Read in a non-exististant value
>>> myFCSXMLAsset.valueForField('BadFieldName')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fcsxml.py", line 702, in valueForField
raise FCSFieldNotFoundError(fieldName)
fcsxml.FCSFieldNotFoundError: "No Field with key:'BadFieldName' exists!"
Lastly, we can load an fcsxml.FCSXMLObject class with values from an fcsxml.FCSVRClient class and output a FCS ReadXML compliant XML file.
## Import our module
>>> import fcsxml
## Create our :class:`fcsxml.FCSVRClient` instance
>>> myFCSVRAsset = fcsxml.FCSVRClient(entityID=32,
entityType='asset',
configParser='/usr/local/etc/transmogrifier.conf')
## Create a field object based on our DB Field name (something FCSXMLObject
## cannot do)
>>> myField = myFCSVRAsset.initFieldWithDBName('CUST_TITLE')
>>> myField.setValue('New Title')
>>> myFCSVRAsset.setField(myField)
## Create our :class:`fcsxml.FCSXMLObject` instance
>>> myFCSXMLAsset = fcsxml.FCSXMLObject()
>>> myFCSXMLAsset.loadFromFCSVRClient(myFCSVRAsset)
## Write our XML file
>>> myFCSXMLAsset.setMD()