Generating Atom feeds using Python and KID

The Atom syndication format is the standard way of making others aware of changes to your web-site, in particular to new content on the website. Atom is based on XML and Atom feeds can be produced very simply and conveniently using Kid and of course Python. Here is on outline on how to do it.

The Kid Template

The following is a sample Kid template:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<feed xmlns="" xmlns:py="">
  <title type="text">Bojan's Blog</title>
  <subtitle type="text">
  A blog on various computing related items by Bojan Nikolic. See .

  <link href="" rel="self"
        title="Bojan's blog feed"/>

  <updated py:content="mostrecent"></updated>

  <entry py:for="b in blist">
     <name>Bojan Nikolic</name>
    <updated py:content="b[3]">
    No date found

  <id py:content="''+b[0]+'.html'"></id>

  <link py:attrs="href=''+b[0]+'.html'"/>

  <title type="text" py:content="b[1]">No title found</title>

  <summary type="html" xml:space="preserve" py:content="b[2]">
  No summary found




The above template uses two python variables:

  • mostrecent which is a string containing the date of the most recent change to the website
  • blist which is a list of 4-tuples: ( post name, title, summary , date created/updated)


From python the kid template can be processed with something like:

def Kiddify(kid_fname,

    fout=open(fnameout, "w")

That is it! In the following article I give the full Python script to generate the Atom feed from a directory of text files.