Book Image

Learning Flask Framework

Book Image

Learning Flask Framework

Overview of this book

Table of Contents (17 chapters)
Learning Flask Framework
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating Atom feeds


A really useful feature for any blog is to have the ability for your readers to keep up-to-date with the latest content. This most commonly happens with an RSS reader client that polls your RSS subscription feed. While RSS is widely used, a better, more mature subscription format is available and is called Atom.

Both are files that can be requested by a client, and are standard and simple XML data structures. Fortunately, an Atom feed generator is built into Flask; or, more specifically, a contributed module is built into the WSGI interface that Flask uses called Werkzeug.

Getting it up-and-running is simple, all we need to do is to get hold of our most recently published posts from the database. It may be best to create a new Blueprint for this; however, you can also do it within your main.py. We just need to make use of a few more modules:

from urlparse import urljoin
from flask import request, url_for
from werkzeug.contrib.atom import AtomFeed
from models import Entry...