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

Module lxml.objectify

Classes
BoolElement Boolean type base on string values: 'true' or 'false'.
FloatElement  
IntElement  
LongElement  
NoneElement  
NumberElement  
ObjectifiedDataElement This is the base class for all data type Elements.
ObjectifiedElement Main XML Element class.
ObjectifyElementClassLookup Element class lookup method that uses the objectify classes.
ObjectPath Immutable object that represents a compiled object path.
PyType User defined type.
StringElement String data class.
_ObjectifyTypemap Type map for the ElementMaker.
_StringValueSetter  

Function Summary
  annotate(...)
Recursively annotates the elements of an XML tree with 'pytype' attributes.
  DataElement(...)
Create a new element from a Python value and XML attributes taken from keyword arguments or a dictionary passed as second argument.
  deannotate(...)
Recursively de-annotate the elements of an XML tree by removing 'pytype' and/or 'type' attributes.
  dump(...)
Return a recursively generated string representation of an element.
  Element(...)
Objectify specific version of the lxml.etree Element() factory that always creates a structural (tree) element.
  enableRecursiveStr(...)
Enable a recursively generated tree representation for str(element), based on objectify.dump(element).
  fromstring(...)
Objectify specific version of the lxml.etree fromstring() function.
  getRegisteredTypes(...)
Returns a list of the currently registered PyType objects.
  parse(...)
  set_default_parser(...)
Replace the default parser used by objectify's Element() and fromstring() functions.
  setDefaultParser(...)
  setPytypeAttributeTag(...)
Changes name and namespace of the XML attribute that holds Python type information.
  XML(...)
Objectify specific version of the lxml.etree fromstring() function.
  xsiannotate(...)
Recursively annotates the elements of an XML tree with 'xsi:type' attributes.
  __add_bool(...)
  __add_none(...)
  __add_stringifiable(...)
  __add_text(...)
  __checkBool(...)
  __lower_bool(...)
  __xsiannotate(...)
Recursively annotates the elements of an XML tree with 'xsi:type' attributes.

Variable Summary
str __version__ = '2.0.dev-45843'
ElementMaker E = <objectify.ElementMaker object at 0x408c590c>
str PYTYPE_ATTRIBUTE = '{http://codespeak.net/lxml/objectify...

Function Details

annotate(...)

Recursively annotates the elements of an XML tree with 'pytype' attributes.

If the 'ignore_old' keyword argument is True (the default), current 'pytype' attributes will be ignored and replaced. Otherwise, they will be checked and only replaced if they no longer fit the current text value.

Setting the keyword argument ``ignore_xsi`` to True makes the function additionally ignore existing ``xsi:type`` annotations. The default is to use them as a type hint.

The default annotation of empty elements can be set with the ``empty_pytype`` keyword argument. The default is not to annotate empty elements. Pass 'str', for example, to make string values the default.

DataElement(...)

Create a new element from a Python value and XML attributes taken from keyword arguments or a dictionary passed as second argument.

Automatically adds a 'pytype' attribute for the Python type of the value, if the type can be identified. If '_pytype' or '_xsi' are among the keyword arguments, they will be used instead.

If the _value argument is an ObjectifiedDataElement instance, its py:pytype, xsi:type and other attributes and nsmap are reused unless they are redefined in attrib and/or keyword arguments.

deannotate(...)

Recursively de-annotate the elements of an XML tree by removing 'pytype' and/or 'type' attributes.

If the 'pytype' keyword argument is True (the default), 'pytype' attributes will be removed. If the 'xsi' keyword argument is True (the default), 'xsi:type' attributes will be removed.

dump(...)

Return a recursively generated string representation of an element.

Element(...)

Objectify specific version of the lxml.etree Element() factory that always creates a structural (tree) element.

NOTE: requires parser based element class lookup activated in lxml.etree!

enableRecursiveStr(...)

Enable a recursively generated tree representation for str(element), based on objectify.dump(element).

fromstring(...)

Objectify specific version of the lxml.etree fromstring() function.

NOTE: requires parser based element class lookup activated in lxml.etree!

getRegisteredTypes(...)

Returns a list of the currently registered PyType objects.

To add a new type, retrieve this list and call unregister() for all entries. Then add the new type at a suitable position (possibly replacing an existing one) and call register() for all entries.

This is necessary if the new type interferes with the type check functions of existing ones (normally only int/float/bool) and must the tried before other types. To add a type that is not yet parsable by the current type check functions, you can simply register() it, which will append it to the end of the type list.

set_default_parser(...)

Replace the default parser used by objectify's Element() and fromstring() functions.

The new parser must be an etree.XMLParser.

Call without arguments to reset to the original parser.

setPytypeAttributeTag(...)

Changes name and namespace of the XML attribute that holds Python type information.

Reset by calling without argument.

Default: "{http://codespeak.net/lxml/objectify/pytype}pytype"

XML(...)

Objectify specific version of the lxml.etree fromstring() function.

NOTE: requires parser based element class lookup activated in lxml.etree!

xsiannotate(...)

Recursively annotates the elements of an XML tree with 'xsi:type' attributes.

If the 'ignore_old' keyword argument is True (the default), current 'xsi:type' attributes will be ignored and replaced. Otherwise, they will be checked and only replaced if they no longer fit the current text value.

Note that the mapping from Python types to XSI types is usually ambiguous. Currently, only the first XSI type name in the corresponding PyType definition will be used for annotation. Thus, you should consider naming the widest type first if you define additional types.

Setting the keyword argument ``ignore_pytype`` to True makes the function additionally ignore existing ``pytype`` annotations. The default is to use them as a type hint.

The default annotation of empty elements can be set with the ``empty_type`` keyword argument. The default is not to annotate empty elements. Pass 'string', for example, to make string values the default.

__xsiannotate(...)

Recursively annotates the elements of an XML tree with 'xsi:type' attributes.

If the 'ignore_old' keyword argument is True (the default), current 'xsi:type' attributes will be ignored and replaced. Otherwise, they will be checked and only replaced if they no longer fit the current text value.

Note that tha mapping from Python types to XSI types is usually ambiguous. Currently, only the first XSI type name in the corresponding PyType definition will be used for annotation. Thus, you should consider naming the widest type first here if you define additional types.

Variable Details

__version__

Type:
str
Value:
'2.0.dev-45843'                                                        

E

Type:
ElementMaker
Value:
<objectify.ElementMaker object at 0x408c590c>                          

PYTYPE_ATTRIBUTE

Type:
str
Value:
'{http://codespeak.net/lxml/objectify/pytype}pytype'                   

Generated by Epydoc 2.1 on Sat Aug 18 12:44:27 2007 http://epydoc.sf.net