Bases: object
Returns a constant.
Bases: nova.api.openstack.xmlutil.Selector
Returns the empty string if Selector would return None.
Bases: nova.api.openstack.xmlutil.Template
Represent a master template.
Master templates are versioned derivatives of templates that additionally allow slave templates to be attached. Slave templates allow modification of the serialized result without directly changing the master.
Attach one or more slave templates.
Attaches one or more slave templates to the master template. Slave templates must have a root element with the same tag as the master template. The slave template’s apply() method will be called to determine if the slave should be applied to this master; if it returns False, that slave will be skipped. (This allows filtering of slaves based on the version of the master template.)
Return a copy of this master template.
Bases: xml.sax.expatreader.ExpatParser
An expat parser which disables DTD’s and entities by default.
Bases: object
Selects datum to operate on from an object.
Bases: nova.api.openstack.xmlutil.Template
Represent a slave template.
Slave templates are versioned derivatives of templates. Each slave has a minimum version and optional maximum version of the master template to which they can be attached.
Hook method for determining slave applicability.
An overridable hook method used to determine if this template is applicable as a slave to a given master template. This version requires the master template to have a version number between min_vers and max_vers.
Parameters: | master – The master template to test. |
---|
Create a template element as a child of another.
Corresponds to the etree.SubElement interface. Parameters are as for TemplateElement, with the addition of the parent.
Bases: object
Represent a template.
Hook method for determining slave applicability.
An overridable hook method used to determine if this template is applicable as a slave to a given master template.
Parameters: | master – The master template to test. |
---|
Create a tree.
Serializes an object against the template. Returns an Element node with appropriate children.
Parameters: | obj – The object to serialize. |
---|
Serialize an object.
Serializes an object against the template. Returns a string with the serialized XML. Positional and keyword arguments are passed to etree.tostring().
Parameters: | obj – The object to serialize. |
---|
Return string representation of the template tree.
Returns a representation of the template as a string, suitable for inclusion in debug logs.
Unwraps a template to return a template element.
Wraps a template element to return a template.
Bases: object
Template builder.
This class exists to allow templates to be lazily built without having to build them each time they are needed. It must be subclassed, and the subclass must implement the construct() method, which must return a Template (or subclass) instance. The constructor will always return the template returned by construct(), or, if it has a copy() method, a copy of that template.
Construct a template.
Called to construct a template instance, which it must return. Only called once.
Bases: object
Represent an element in the template.
Append a child to the element.
Apply text and attributes to an etree.Element.
Applies the text and attribute instructions in the template element to an etree.Element instance.
Parameters: |
|
---|
Append children to the element.
Get an attribute.
Returns a callable which performs datum selection.
Parameters: | key – The name of the attribute to get. |
---|
Insert a child element at the given index.
Return the attribute names and values.
Return the attribute names.
Remove a child element.
Render an object.
Renders an object against this template node. Returns a list of two-item tuples, where the first item is an etree.Element instance and the second item is the datum associated with that instance.
Parameters: |
|
---|
Set an attribute.
Parameters: |
|
---|
Template element text.
Either None or a callable taking an object and optional boolean do_raise indicator and returning the datum bound to the text of the template element.
Return string representation of the template tree.
Returns a representation of the template rooted at this element as a string, suitable for inclusion in debug logs.
Unwraps a template to return a template element.
Hook method.
An overridable hook method to determine whether this template element will be rendered at all. By default, returns False (inhibiting rendering) if the datum is None.
Parameters: | datum – The datum associated with this template element. |
---|
Wraps a template element to return a template.
Get items in obj.
Utility for simple XML templates that traditionally used XMLDictSerializer with no metadata. Returns a template element where the top-level element has the given tag name, and where sub-elements have tag names derived from the object’s keys and text derived from the object’s values. This only works for flat dictionary objects, not dictionaries containing nested lists or dictionaries.
Attach an Atom <links> element to the parent.
Parse an XML string using minidom safely.