[lxml-dev] XPathModel

Hi! I had mentioned something about my XPath model a while ago and there was some interest. I now uploaded the project that I wrote it for to Berlios, so the module is now available here: http://svn.berlios.de/wsvn/slow/trunk/src/slow/model/xpathmodel.py?op=file&rev=0&sc=0 It (obviously) uses the namespace extension mechanism that I wrote for lxml. The implementation is basically a metaclass that allows you to write XPath expressions into the body of a Python class and then transforms them at class creation time into getter and setter methods or properties (if possible). It's pretty sophisticated: it supports XPath variables as method arguments, filters for simple XPath result conversion and on-the-fly construction of XML elements. It's even more home grown by need, so it may be a bit difficult to understand at first sight. The package of that module contains a number of other modules that use the XPathModel class to implement various kinds of data class APIs, they may be a good starting point. Hope you like it, Stefan
participants (1)
-
Stefan Behnel