How to serve LibX 2.0 Libapps with WSGI

As described in the LibX 2.0 Specification, LibX 2.0 packages, libapps, and modules are published as an Atom store.

In order to avoid storing and editing XML files directly, these Atom feeds are created from text description files using a Python WSGI module. 

All description files located within the same directory are served within the same feed.

The suffix determines the type of entry: .mod files describe Modules, .app files describe LibApps, and .pkg files describe Packages.

The file format itself is described by RFC 822. It consists of a header and a body. 

Each header line is translated into a <libx:*> element. For instance,

Include: /.*/

is translated into <libx:include>/.*/</libx:include>.

The body is interpreted differently for modules as for libapps and packages.

For modules, the body is simply embedded as <libx:body>…</libx:body>.

For libapps and packages, each line in the body is translated into a <libx:entry> element. The content of the line becomes the content of the src=”" attribute.

Caveats

The code is tested using mod_wsgi and Apache 2. It requires careful configuration of a .htaccess file. It uses Luke Arno’s selector library and a heavily modified version of Django AtomPub.