[Erp5-report] r39721 nicolas - in /erp5/trunk/utils/xml_marshaller: CHANGES.txt README.txt

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Oct 30 18:55:51 CEST 2010


Author: nicolas
Date: Sat Oct 30 18:55:50 2010
New Revision: 39721

URL: http://svn.erp5.org?rev=39721&view=rev
Log:
add description and example in README.txt

Modified:
    erp5/trunk/utils/xml_marshaller/CHANGES.txt
    erp5/trunk/utils/xml_marshaller/README.txt

Modified: erp5/trunk/utils/xml_marshaller/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/CHANGES.txt?rev=39721&r1=39720&r2=39721&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/CHANGES.txt [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/CHANGES.txt [utf8] Sat Oct 30 18:55:50 2010
@@ -5,7 +5,7 @@ History
 ------------------
 
 
-0.9.7 (2010-10-28)
+0.9.7 (2010-10-30)
 ---------------------
  - Enhance egg folder structure
     [nicolas Delaby]

Modified: erp5/trunk/utils/xml_marshaller/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/README.txt?rev=39721&r1=39720&r2=39721&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/README.txt [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/README.txt [utf8] Sat Oct 30 18:55:50 2010
@@ -1,7 +1,65 @@
+Introduction
+============
+
 Marshals simple Python data types into a custom XML format.
 The Marshaller and Unmarshaller classes can be subclassed in order
 to implement marshalling into a different XML DTD.
 Original Authors are XML-SIG (xml-sig at python.org).
+
 Fully compatible with PyXML implementation, enable namespace support for
 XML Input/Output.
-Implemented with lxml
\ No newline at end of file
+
+Implemented with lxml
+
+Installation
+============
+
+python setup.py install
+
+
+Testing
+=======
+
+python setup.py test
+
+Usage
+=====
+
+For simple serialisation and unserialisation::
+
+
+  >>> from xml_marshaller import xml_marshaller
+  >>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}])
+  '<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><unicode>unicode string</unicode></dictionary></list></marshal>'
+  >>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}]))
+  ['item1', {'key2': u'unicode string', 'key1': 1}]
+
+Can works with file like objects::
+
+
+  >>> from xml_marshaller import xml_marshaller
+  >>> from StringIO import StringIO
+  >>> file_like_object = StringIO()
+  >>> xml_marshaller.dump('Hello World !', file_like_object)
+  >>> file_like_object.seek(0)
+  >>> file_like_object.read()
+  '<marshal><string>Hello World !</string></marshal>'
+  >>> file_like_object.seek(0)
+  >>> xml_marshaller.load(file_like_object)
+  'Hello World !'
+
+xml_marshaller can also output xml with qualified names::
+
+
+  >>> from xml_marshaller import xml_marshaller
+  >>> xml_marshaller.dumps_ns('Hello World !')
+  '<marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller"><marshal:string>Hello World !</marshal:string></marshal:marshal>'
+
+
+You can also use your own URI::
+
+  >>> from xml_marshaller.xml_marshaller import Marshaller
+  >>> marshaller = Marshaller(namespace_uri='http://my-custom-namespace-uri/namespace')
+  >>> marshaller.dumps('Hello World !')
+  '<marshal:marshal xmlns:marshal="http://my-custom-namespace-uri/namespace"><marshal:string>Hello World !</marshal:string></marshal:marshal>'
+




More information about the Erp5-report mailing list