Nuclear Power, More Pythonic

"Atomkraft, ja bitte!" Since I came across the Atom content syndication format (RFC 4287) for the first time, my decision was clear to replace all creepy RSS stuff I had done so far. In lack of a (Python) package, I used the respective template engine to create an Atom feed for a website. Then I heard of the release of a new package, Atomixlib by Sylvain Hellegouarch.

Unfortunately, it used the 4Suite-based Amara XML Toolkit. Not only was I already happy with pure-Python ElementTree (ET), 4Suite also has C dependencies which didn't allow me to install it on webspace without shell access. Maybe it's possible today to get around that restriction by using Python eggs and getting setuptools installed somehow over FTP only (like it works with pure-Python packages, after adding them to PYTHONPATH).

As a result, an Atomixlib port to ET has been on my list nearly since I knew about it. But then, a few days ago, I saw that Atomixlib already got ported to ET by Andrew Ittner - thanks!

I just finished porting the feeds here on homework to Atomixlib and I'm reasonably satisfied with the result. The ET-based module has a few bugs in it since Sylvain doesn't use it himself (as he stated in his very quick response to my email). I'll send a complete patch with everything I found so far.

A more serious issue is that there is no support for indentation with ET yet. Although feeds are normally read by machines, it is sometimes valuable to be able to take a look oneself. Furthermore, this code ...

from xml.dom.minidom import parseString

feed = atomixlib.create_feed()
print parseString(str(feed)).toprettyxml(' ' * 4)

... doesn't help either since PCDATA in elements is put on a single line, thus breaking the validity of the feed. However, after a quick look into the xml.dom.minidom module, I think a few adjustments should make that work. For now, I will do without. Any ideas are welcome.

Update: Sylvain has released version 0.4.4 which incorporates fixes (some of them by me for the ET engine) as well as support for the Atom Publishing Protocol's categories element.

Update: I wrote about a way to achieve indentation.