[Lxml-checkins] r46657 - lxml/trunk/src/lxml
scoder at codespeak.net
scoder at codespeak.net
Sat Sep 15 21:40:56 CEST 2007
Author: scoder
Date: Sat Sep 15 21:40:56 2007
New Revision: 46657
Modified:
lxml/trunk/src/lxml/etree.pyx
lxml/trunk/src/lxml/objectify.pyx
Log:
comment on deprecation of getchildren(), copied over to objectify where it is still needed anyway
Modified: lxml/trunk/src/lxml/etree.pyx
==============================================================================
--- lxml/trunk/src/lxml/etree.pyx (original)
+++ lxml/trunk/src/lxml/etree.pyx Sat Sep 15 21:40:56 2007
@@ -973,6 +973,9 @@
def getchildren(self):
"""Returns all direct children. The elements are returned in document
order.
+
+ Note that this method has been deprecated as of ElementTree 1.3. New
+ code should use ``list(element)`` or simply iterate over elements.
"""
cdef xmlNode* c_node
cdef int ret
Modified: lxml/trunk/src/lxml/objectify.pyx
==============================================================================
--- lxml/trunk/src/lxml/objectify.pyx (original)
+++ lxml/trunk/src/lxml/objectify.pyx Sat Sep 15 21:40:56 2007
@@ -188,6 +188,23 @@
c_node = c_node.next
return c
+ def getchildren(self):
+ """Returns a sequence of all direct children. The elements are
+ returned in document order.
+ """
+ cdef xmlNode* c_node
+ cdef int ret
+ result = []
+ c_node = self._c_node.children
+ while c_node is not NULL:
+ if _isElement(c_node):
+ ret = python.PyList_Append(
+ result, _elementFactory(self._doc, c_node))
+ if ret:
+ raise
+ c_node = c_node.next
+ return result
+
def __getattr__(self, tag):
"""Return the (first) child with the given tag name. If no namespace
is provided, the child will be looked up in the same one as self.
More information about the lxml-checkins
mailing list