Package pyxsd :: Package elementRepresentatives :: Module attribute :: Class Attribute
[hide private]
[frames] | no frames]

Class Attribute

source code

                                 object --+    
                                          |    
elementRepresentative.ElementRepresentative --+
                                              |
                                             Attribute

The class for the attribute tag. Subclass of ElementRepresentative. The element tag and the attribute tag are the most important in the xml and in the program, so this class contains some machinery that many of the other classes do not have. The element and attribute classes contain descriptor methods. By specifing the __get__, __set__, and __delete__ (with __get__ and __set__ being the most important). These methods specify how a variable is set and how it retrieved. Any modification of these methods should be made under extreme caution! Both Element and Attribute, primarily Attribute, use these descriptors to add a level oof checking to the program. If some variable is set to some value that does no match the specifications in the schema, an error will be raised. These methods add a powerful layer of functionality, with a small amount of code; however, these functions are almost invisible unless they raise an error, so developers should bear in mind these methods when modifying the program.

Instance Methods [hide private]
  __init__(self, xsdElement, parent)
Adds itself to the attribute dictionary in its containing type.
  __str__(self)
Prints its name in a form that allows for quick identification of an attribute, without needing a bulky name that does not match the name used.
  processChildren(self)
There is a special processChildren() here to handle special types, which can be declared as a child of an attribute.
  getType(self)
Returns its type from the class dictionary in PyXSD.
  __get__(self, obj, mystery=None)
Gets an attribute value from the obj's dictionary.
  __set__(self, obj, value)
Sets values to attributes.
  __delete__(self, obj)
Deletes an entry from the dictionary.
  getUse(self)
Returns the 'use' value, which says if the attribute is required or the default optional.

Inherited from elementRepresentative.ElementRepresentative: addSuperClassName, checkTopLevelType, describe, findLayerNum, getContainingType, getContainingTypeName, getName, getSchema

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


Class Methods [hide private]

Inherited from elementRepresentative.ElementRepresentative: classNameFor, factory, getFromName, register, typeFromName


Static Methods [hide private]

Inherited from elementRepresentative.ElementRepresentative: tryConvert


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, xsdElement, parent)
(Constructor)

source code 
Adds itself to the attribute dictionary in its containing type. See ElementRepresentative for documentation.
Overrides: elementRepresentative.ElementRepresentative.__init__

__str__(self)
(Informal representation operator)

source code 
Prints its name in a form that allows for quick identification of an attribute, without needing a bulky name that does not match the name used.
Overrides: elementRepresentative.ElementRepresentative.__str__

processChildren(self)

source code 

There is a special processChildren() here to handle special types, which can be declared as a child of an attribute. If an attribute child can exist that is not a type, then this function will screw it up; however, as far as the developers knew at the time of writing this program, they cannot.

No parameters.

Overrides: elementRepresentative.ElementRepresentative.processChildren

getType(self)

source code 
Returns its type from the class dictionary in PyXSD. The instance of PyXSD is attached to every element and attribute while the classes for the schema types are being built. Clearly, this function is used after the main ER run.

__get__(self, obj, mystery=None)

source code 

Gets an attribute value from the obj's dictionary. Returns it value if it has one, returns the default value if it does not.

The second argument is called mystery. It does not do anything, so it should not really be thought of as a parameter to this method. This variable is needed because of, you guessed it, a mystery. Sometimes, but not every time, the obj is passed in as an instance and it corresponding class. Perhaps it is slightly different, but it does this very odd thing with only some of the attributes/elements. As far as I can tell, the 'mystery' does not cause any problems, but it is a bug, and should be fixed if possible.

See python documentation for full documentation on descriptors. Some links should be included on the pyXSD website.

__set__(self, obj, value)

source code 

Sets values to attributes. Converts text Boolean values to binary values (integers of 0 and 1).

See python documentation for full documentation on descriptors. Some links should be included on the pyXSD website.

__delete__(self, obj)

source code 

Deletes an entry from the dictionary.

See python documentation for full documentation on descriptors. Some links should be included on the pyXSD website.

getUse(self)

source code 
Returns the 'use' value, which says if the attribute is required or the default optional.