Package pyxslt :: Module serialize :: Class Serializer
[frames | no frames]

Type Serializer

object --+
         |
        Serializer


Serializes Python objects to XML documents.
Method Summary
  __init__(self, rootTagName, ignoreRelationship)
Create a Serializer object that can be used to serialize one or more sets of Python elements.
  __del__(self)
Free the memory used by the Serializer object.
  __str__(self)
  serialize(self, **elements)
Serialize one or more Python objects.
  serializeOne(self, element)
Serialize a single Python object directly under the root node.
str toString(self, encoding, prettyPrintXml)
Return the textual version of the XML document that contains the most-recently serialized set of Python objects.
libxml2.xmlDoc toXmlDoc(self)
Return a (copy of) the libxml2.xmlDoc that contains the contents of the most-recently serialized set of Python objects.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Instance Variable Summary
list of className, propName tuples ignoreRelationship: A list of className, propName tuples that describe properties that should not be serialized.
str rootTagName: The name of the root tag in the XML document that will be created during the serialization process.
libxml2.xmlDoc xmlDoc: The XML document that contains the contents of the most-recently serialized set of Python objects.

Method Details

__init__(self, rootTagName='pyxslt', ignoreRelationship=[])
(Constructor)

Create a Serializer object that can be used to serialize one or more sets of Python elements.
Parameters:
rootTagName - The name of the root tag in the XML document that will be created during the serialization process.
           (type=str)
ignoreRelationship - A list of className, propName tuples that describe properties that should not be serialized. These properties will be skipped during the serialization process and will not appear in their parent's output tree. Note that, if the elided property is itself an object and that object has an 'id' property, then a reference to the elided object will be inserted. This is most commonly seen in the case of a sqlobject.ForeignKey relationship.
           (type=list of className, propName tuples)
Overrides:
__builtin__.object.__init__

__del__(self)
(Destructor)

Free the memory used by the Serializer object.

serialize(self, **elements)

Serialize one or more Python objects. This method only accepts keyword arguments. Each value in the argument dictionary will be serialized into the document under a tag with the name of the keyword.

serializeOne(self, element)

Serialize a single Python object directly under the root node. Unlike the serialize method, serializeOne will not wrap the serialized object in an enclosing tag (other than the root tag).

toString(self, encoding='ASCII', prettyPrintXml=False)

Return the textual version of the XML document that contains the most-recently serialized set of Python objects.
Returns:
The most-recently serialized Python objects as an XML document.
           (type=str)

toXmlDoc(self)

Return a (copy of) the libxml2.xmlDoc that contains the contents of the most-recently serialized set of Python objects. It is the responsibility of the caller to free this document.
Returns:
The XML document that contains the contents of the most-recently serialized set of Python objects. This object must be freed by the caller.
           (type=libxml2.xmlDoc)

Instance Variable Details

ignoreRelationship

A list of className, propName tuples that describe properties that should not be serialized. These properties will be skipped during the serialization process and will not appear in their parent's output tree. Note that, if the elided property is itself an object and that object has an 'id' property, then a reference to the elided object will be inserted. This is most commonly seen in the case of a sqlobject.ForeignKey relationship.
Type:
list of className, propName tuples

rootTagName

The name of the root tag in the XML document that will be created during the serialization process.
Type:
str

xmlDoc

The XML document that contains the contents of the most-recently serialized set of Python objects. This object will be freed by the Serializer class as soon as a new call to serialize or serializeOne is made. Do not cache this object and do not free it. Most users of the Serializer class should call toXmlDoc to obtain a copy of the xmlDoc object instead of accessing the property directly.
Type:
libxml2.xmlDoc

Generated by Epydoc 2.1 on Wed Jul 12 11:19:10 2006 http://epydoc.sf.net