[Erp5-report] r35839 nicolas - in /erp5/trunk/utils/xml_marshaller: ./ xml_marshaller/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon May 31 19:24:24 CEST 2010
Author: nicolas
Date: Mon May 31 19:24:23 2010
New Revision: 35839
URL: http://svn.erp5.org?rev=35839&view=rev
Log:
add load_tree function
Modified:
erp5/trunk/utils/xml_marshaller/setup.py
erp5/trunk/utils/xml_marshaller/xml_marshaller/xml_marshaller.py
Modified: erp5/trunk/utils/xml_marshaller/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/setup.py?rev=35839&r1=35838&r2=35839&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/setup.py [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/setup.py [utf8] Mon May 31 19:24:23 2010
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os
-version = '0.9'
+version = '0.9a'
setup(name='xml_marshaller',
version=version,
Modified: erp5/trunk/utils/xml_marshaller/xml_marshaller/xml_marshaller.py
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/xml_marshaller/xml_marshaller.py?rev=35839&r1=35838&r2=35839&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/xml_marshaller/xml_marshaller.py [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/xml_marshaller/xml_marshaller.py [utf8] Mon May 31 19:24:23 2010
@@ -13,7 +13,7 @@
import sys
from xml.sax import make_parser
from xml.sax.saxutils import escape, unescape
-from lxml.sax import ElementTreeContentHandler
+from lxml.sax import ElementTreeContentHandler, saxify
from lxml import etree
from lxml.builder import ElementMaker
from cStringIO import StringIO
@@ -300,6 +300,18 @@
m = self.__class__()
return m._load(file_object)
+ def load_tree(self, tree):
+ """Unmarshal element_tree object and return
+ python object.
+ """
+ parser = make_parser()
+ parser.setFeature('http://xml.org/sax/features/namespaces', True)
+ parser.setContentHandler(self)
+ saxify(tree, self)
+ result = self.data_stack[0]
+ self._clear()
+ return result
+
def loads(self, string):
"Unmarshal one value from a string"
# Instantiate a new object; unmarshalling isn't thread-safe
@@ -552,6 +564,7 @@
_um = Unmarshaller()
load = _um.load
loads = _um.loads
+load_tree = _um.load_tree
del _m, _um, _m_ns
More information about the Erp5-report
mailing list