commiting some Python bindings work done while travelling Daniel

* python/*: commiting some Python bindings work done while travelling
Daniel
diff --git a/ChangeLog b/ChangeLog
index d646dc0..cd6c420 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Mar  1 13:56:12 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+	* python/*: commiting some Python bindings work done while travelling
+
 Fri Mar  1 10:11:15 CET 2002 Daniel Veillard <daniel@veillard.com>
 
 	* xmllint.c: close #72663 and #72658, don't memdump unless compiled
diff --git a/python/libxml.c b/python/libxml.c
index f81ebb7..f79af7d 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -1404,6 +1404,30 @@
 
 /************************************************************************
  *									*
+ *			Extra stuff					*
+ *									*
+ ************************************************************************/
+PyObject *
+libxml_xmlNewNode(PyObject *self, PyObject *args) {
+    PyObject *py_retval;
+    xmlChar * name;
+    xmlNodePtr node;
+
+    if (!PyArg_ParseTuple(args, "s:xmlNewNode", &name))
+        return(NULL);
+    node = (xmlNodePtr) xmlNewNode(NULL, name);
+    printf("NewNode: %s : %p\n", name, node);
+
+    if (node == NULL) {
+	Py_INCREF(Py_None);
+	return(Py_None);
+    }
+    py_retval = libxml_xmlNodePtrWrap(node);
+    return(py_retval);
+}
+
+/************************************************************************
+ *									*
  *			The registration stuff				*
  *									*
  ************************************************************************/
@@ -1418,6 +1442,7 @@
     { "parent", libxml_parent, METH_VARARGS, NULL },
     { "type", libxml_type, METH_VARARGS, NULL },
     { "doc", libxml_doc, METH_VARARGS, NULL },
+    { "xmlNewNode", libxml_xmlNewNode, METH_VARARGS, NULL },
     { NULL }
 };
 
diff --git a/python/libxml2-python-api.xml b/python/libxml2-python-api.xml
index 4777319..5026ee1 100644
--- a/python/libxml2-python-api.xml
+++ b/python/libxml2-python-api.xml
@@ -1,10 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <api name='libxml2-python'>
-  <files>
-    <file name='python'>
-     <exports symbol='libxml_registerXPathFunction'/>
-    </file>
-  </files>
   <symbols>
     <function name='xmlRegisterXPathFunction' file='python'>
       <info>Register a Python written function to the XPath interpreter</info>
@@ -14,6 +9,11 @@
       <arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
       <arg name='f' type='pythonObject' info='the python function'/>
     </function>
+    <function name='xmlNewNode' file='python'>
+      <info>Create a new Node</info>
+      <return type='xmlNodePtr' info="A new element node"/>
+      <arg name='name' type='xmlChar *' info='the node name'/>
+    </function>
     <function name='xmlRegisterErrorHandler' file='python'>
       <info>Register a Python written function to for error reporting. The function is called back as f(ctx, error).</info>
       <return type='int' info="1 in case of success, 0 or -1 in case of error"/>
diff --git a/python/libxml2class.txt b/python/libxml2class.txt
index 0b78625..16cab8e 100644
--- a/python/libxml2class.txt
+++ b/python/libxml2class.txt
@@ -121,6 +121,7 @@
 debugMemory()
 dumpMemory()
 htmlCreatePushParser()
+newNode()
 registerErrorHandler()
 
 # functions from module tree
@@ -343,7 +344,6 @@
     copyNamespaceList()
     freeNs()
     freeNsList()
-    newNode()
 
 
 Class xmlDtd(xmlNode)
diff --git a/python/types.c b/python/types.c
index d9fbd94..81865df 100644
--- a/python/types.c
+++ b/python/types.c
@@ -346,7 +346,7 @@
 
 xmlXPathObjectPtr
 libxml_xmlXPathObjectPtrConvert(PyObject * obj) {
-    xmlXPathObjectPtr ret;
+    xmlXPathObjectPtr ret = NULL;
 
 #ifdef DEBUG
     printf("libxml_xmlXPathObjectPtrConvert: obj = %p\n", obj);
@@ -362,6 +362,25 @@
 	str = xmlStrndup((const xmlChar *)PyString_AS_STRING(obj),
 		         PyString_GET_SIZE(obj));
 	ret = xmlXPathWrapString(str);
+    } else if PyList_Check(obj) {
+	int i;
+	PyObject *node;
+	xmlNodePtr cur;
+	xmlNodeSetPtr set;
+
+	set = xmlXPathNodeSetCreate(NULL);
+
+	for (i = 0;i < PyList_Size(obj);i++) {
+	    node = PyList_GetItem(obj, i);
+	    if ((node == NULL) || (node->ob_type == NULL) ||
+		(!PyCObject_Check(node)))
+		continue;
+	    cur = PyxmlNode_Get(node);
+	    if (cur != NULL) {
+		xmlXPathNodeSetAdd(set, cur);
+	    }
+	}
+	ret = xmlXPathWrapNodeSet(set);
     } else {
 	printf("Unable to convert Python Object to XPath");
     }