Package lxml :: Module objectify :: Class PyType
[hide private]
[frames] | no frames]

Class PyType

object --+
         |
        PyType

PyType(self, name, type_check, type_class, stringify=None) User defined type.

Named type that contains a type check function and a type class that inherits from ObjectifiedDataElement. The type check must take a string as argument and raise ValueError or TypeError if it cannot handle the string value. It may be None in which case it is not considered for type guessing.

Example:

PyType('int', int, MyIntClass).register()

Note that the order in which types are registered matters. The first matching type will be used.

Instance Methods [hide private]
 
__init__(self, name, type_check, type_class, stringify=None)
x.__init__(...) initializes x; see help(type(x)) for signature
a new object with type S, a subtype of T
__new__(T, S, ...)
 
__repr__(x)
repr(x)
 
register(self, before=None, after=None)
Register the type.
 
unregister(self)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  name
  stringify
  type_check
  xmlSchemaTypes
The list of XML Schema datatypes this Python type maps to.

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, type_check, type_class, stringify=None)
(Constructor)

 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__

__new__(T, S, ...)

 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__repr__(x)
(Representation operator)

 
repr(x)
Overrides: object.__repr__

register(self, before=None, after=None)

 

Register the type.

The additional keyword arguments 'before' and 'after' accept a sequence of type names that must appear before/after the new type in the type list. If any of them is not currently known, it is simply ignored. Raises ValueError if the dependencies cannot be fulfilled.


Property Details [hide private]

xmlSchemaTypes

The list of XML Schema datatypes this Python type maps to.

Note that this must be set before registering the type!