Package pyxb :: Package binding :: Module content :: Class AttributeUse
[hide private]
[frames] | no frames]

Class AttributeUse

source code

object --+    
         |    
   cscRoot --+
             |
            AttributeUse

A helper class that encapsulates everything we need to know about the way an attribute is used within a binding class.

Attributes are stored internally as pairs (provided, value), where provided is a boolean indicating whether a value for the attribute was provided externally, and value is an instance of the attribute datatype. The provided flag is used to determine whether an XML attribute should be added to a created DOM node when generating the XML corresponding to a binding instance.

Instance Methods [hide private]
 
__init__(self, name, id, key, data_type, unicode_default=None, fixed=False, required=False, prohibited=False)
Create an AttributeUse instance.
source code
pyxb.namespace.ExpandedName
name(self)
The expanded name of the element.
source code
 
defaultValue(self)
The default value of the attribute.
source code
 
fixed(self)
True iff the value of the attribute cannot be changed.
source code
 
required(self)
Return True iff the attribute must be assigned a value.
source code
 
prohibited(self)
Return True iff the attribute must not be assigned a value.
source code
 
provided(self, ctd_instance)
Return True iff the given instance has been explicitly given a value for the attribute.
source code
 
id(self)
Tag used within Python code for the attribute.
source code
 
key(self)
String used as key within object dictionary when storing attribute value.
source code
 
dataType(self)
The subclass of pyxb.binding.basis.simpleTypeDefinition of which any attribute value must be an instance.
source code
 
__getValue(self, ctd_instance)
Retrieve the value information for this attribute in a binding instance.
source code
 
__getProvided(self, ctd_instance) source code
 
value(self, ctd_instance)
Get the value of the attribute from the instance.
source code
 
__setValue(self, ctd_instance, new_value, provided) source code
 
reset(self, ctd_instance)
Set the value of the attribute in the given instance to be its default value, and mark that it has not been provided.
source code
 
addDOMAttribute(self, dom_support, ctd_instance, element)
If this attribute as been set, add the corresponding attribute to the DOM element.
source code
 
validate(self, ctd_instance) source code
 
set(self, ctd_instance, new_value)
Set the value of the attribute.
source code
 
_description(self, name_only=False, user_documentation=True) source code

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

Class Variables [hide private]
  __name = None
  __id = None
  __key = None
  __dataType = None
  __unicodeDefault = None
  __defaultValue = None
  __fixed = False
  __required = False
  __prohibited = False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, id, key, data_type, unicode_default=None, fixed=False, required=False, prohibited=False)
(Constructor)

source code 

Create an AttributeUse instance.

Parameters:
  • name (pyxb.namespace.ExpandedName) - The name by which the attribute is referenced in the XML
  • id (str) - The Python identifier for the attribute within the containing pyxb.basis.binding.complexTypeDefinition. This is a public identifier, derived from the local part of the attribute name and modified to be unique, and is usually used as the name of the attribute's inspector method.
  • key (str) - The string used to store the attribute value in the dictionary of the containing pyxb.basis.binding.complexTypeDefinition. This is mangled so that it is unique among and is treated as a Python private member.
  • data_type (type) - The class reference to the subclass of pyxb.binding.basis.simpleTypeDefinition of which the attribute values must be instances.
  • unicode_default (unicode) - The default value of the attribute as specified in the schema, or None if there is no default attribute value. The default value (of the keyword) is None.
  • fixed (bool) - If True, indicates that the attribute, if present, must have the value that was given via unicode_default. The default value is False.
  • required (bool) - If True, indicates that the attribute must appear in the DOM node used to create an instance of the corresponding pyxb.binding.basis.complexTypeDefinition. The default value is False. No more that one of required and prohibited should be assigned True.
  • prohibited (bool) - If True, indicates that the attribute must not appear in the DOM node used to create an instance of the corresponding pyxb.binding.basis.complexTypeDefinition. The default value is False. No more that one of required and prohibited should be assigned True.
Raises:
Overrides: object.__init__

provided(self, ctd_instance)

source code 

Return True iff the given instance has been explicitly given a value for the attribute.

This is used for things like only generating an XML attribute assignment when a value was originally given (even if that value happens to be the default).

id(self)

source code 

Tag used within Python code for the attribute.

This is not used directly in the default code generation template.

__getValue(self, ctd_instance)

source code 

Retrieve the value information for this attribute in a binding instance.

Parameters:
Returns:
(provided, value) where provided is a bool and value is None or an instance of the attribute's datatype.

set(self, ctd_instance, new_value)

source code 

Set the value of the attribute.

This validates the value against the data type, creating a new instance if necessary.

Parameters:
  • ctd_instance (subclass of pyxb.binding.basis.complexTypeDefinition) - The binding instance for which the attribute value is to be set
  • new_value (An xml.dom.Node instance, or any value that is permitted as the input parameter to the Factory method of the attribute's datatype.) - The value for the attribute