[owslib-devel] lxml and owslib/etree.py

Tom Kralidis tomkralidis at hotmail.com
Mon Dec 26 12:01:45 PST 2011


Currently, XML library loading in owslib is wrapped in owslib/etree.py [1], which sets the appropriate library according to what the wrapper finds for python XML libs via try/except with imports.  Calling modules always see owslib.etree as a result.

The current behaviour of [1] is as follows:

- try to load elementtree.ElementTree and patch namespaces
- if that fails, try to load xml.etree.ElementTree and patch namespaces
- if that fails, try to load lxml.etree
- if that fails, raise error

I propose we reverse this order so that lxml.etree is looked for _first_, then xml.etree.ElementTree, then elementtree.ElementTree.  This would ensure that lxml.etree would be loaded first to take advantage of features of lxml (which may not be in owslib, but the calling app[s] use/call), and elementtree.ElementTree would be called as the last resort.

The proposed patch is at http://pastebin.com/bEs4H00E for review and comment.

Any objections or comments?

Thanks

..Tom

[1] https://owslib.svn.sourceforge.net/svnroot/owslib/trunk/owslib/etree.py
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/owslib-devel/attachments/20111226/fb95d180/attachment.html>


More information about the OWSLib-devel mailing list