PyATOM for static site syndication

Bitten by the bug to write more and for others, I've brought back syndication (via Atom rather than RSS) to the blog. I found a few hundred subscribers still checking in on me, so thanks to you all for sticking around. As I run a static site, generating RSS can be a bit of a pain.

After a brief search of not finding anything for generating RSS or Atom for static blogs, I started writing something in Go which would take a YAML file and dump it into an ATOM format. A bit demoralized with the state of YAML parsers (nothing seemingly working), I swapped over to python. I was about to write a naive Atom dumper with a small templating language, when I came across PyAtom. Thanks to Python's readable syntax, it makes for a fantastic feed writing format. As an example, this is the atom feed of this blog with the last entry populated.

from pyatom import AtomFeed
import datetime

feed = AtomFeed(title="Justin Abrahms",
                author="Justin Abrahms")

# Do this for each feed entry
feed.add(title="Why I made pisces, a testable web framework",
         content="Pisces is a Python web framework that was written with testing in mind. It was birthed as a reaction to the typical workflow in a Django project, which I've come to dislike as it encourages you to make your code tightly coupled and less testable.",
         author="Justin Abrahms",
         updated=datetime.datetime(2013, 7, 9, 12, 00))

print feed.to_string()
© 2012 - 2023 · Home — Theme Simpleness