![]() |
mercredi 9 février 2005 |
Infrae pushing XML in Python and ZopeMost of us know that Silva is the XML-oriented CMS for Zope. Recently, Martijn Faassen has been working on two efforts in this area. The first is lxml, a more Pythonic and more stable wrapper around the libxml2 and libxslt GNOME libraries for XML. His interfaces uses the ElementTree API for Python. I've used it a bit recently and it is already in good shape.Lately he has added support for extensions written in Python that can be called from an XPath evaluator. The you can pass an argument to your Python function. It can operate on the current node, or it could issue a database query and return a node set. For example, imagine a Python function that found all the invoices in a MySQL table. You could write an XPath like this: invoices('pending')/invoice[customer[@id='acme']]. The Python function "invoice" would take the argument 'pending', get some records, and return a node with all the pending invoices. The rest of the XPath expression would narrow that down to invoice entries from a certain customer. Note that XPath can also do simple functions, like sum totals. In Silva, Martijn has added support for generic XML documents that can be formatted using XSLT. The XSLT can be registered beforehand and made available like a service, using a drop-down menu, or the XSLT can be entered in a form. The XML can be looked up from in Silva, from a remote URL, or pasted in a textarea.
Martijn is just getting started, but he's already made a tremendous amount of progress. Anybody that is interested in supporting XML in Zope should get in touch with Infrae. |