Re: [xml] Support for Python

On Fri, 25 Jan 2002, Daniel Veillard wrote:

On Thu, Jan 24, 2002 at 04:57:39PM -0800, Dave Kuhlman wrote:

     * Because I used SWIG's shadow classes, the doc, nodes, and
       attributes look, from Python's point of view like instances of
       classes. So, walking the DOM tree is very easy and natural.

  Sounds a good idea, I need to look at the generated code. Anover way
is to make minimal wrappers and build more object oriented classes on
top of the raw function, defining the classes at the Python level.

It's a lot nicer defining the classes in Python than in C, and you have 
the added benefit that it is a lot easier for someone trying to use the 
library to see how it works.

Also (but don't quote me on this) I'm not sure that you can derive
subclasses from classes defined in C modules. I was was unable to find a C
module that exports a class to test however.

     * One qualification is that the interface is at the level of the
       libxml, so it's a bit low level. For example, a long running
       application would have to call a 'free' method, e.g. xmlFreeDoc,
       which is not something a Python programmer would expect to have to

  Hum, keeping reference counting for xmlDocPtr is nearly impossible,
I doubt there is a workaround. Well this need more thinking, the idea
of having to call a at the end of the processing doesn't sound
that bad.

If we write the classes in Python then this is trivial -- call xmlFreeDoc 
in the XmlDocumentClass's destructor and let Python's garbage collector 
work out when to do it.


[ gary inauspicious org ][ GnuPG 85A8F78B ][ ]

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]