Write out Atom Feed XML

21 views
Skip to first unread message

jago

unread,
Nov 8, 2008, 8:59:44 AM11/8/08
to Google App Engine
Hi,

I would like to write out the XML of an Atom feed. Is there a lib
which is part of the standard AppEngine setup which could help me
writing the XML?

Or should I simple construct the xml string 'by hand' ?


isa

Sylvain

unread,
Nov 8, 2008, 10:49:32 AM11/8/08
to Google App Engine
For my app, I use 2 ideas :

- http://bloog.billkatz.com/ (source available). It uses the webapp
template engine.
- http://home.avvanta.com/~steveha/pyfeed.html : only for the utility
methods (rfc339 and tag)

Then if I need to update the atom.xml template, I go there :
http://www.atomenabled.org/developers/syndication/

If you use a template, update self.response.headers['Content-Type'] =
'text/xml'

Regards

Alexander Kojevnikov

unread,
Nov 8, 2008, 7:28:51 PM11/8/08
to Google App Engine
I do generate the feed 'by hand', it's pretty simple.

Make sure your feed validates:
http://validator.w3.org/feed/

jago

unread,
Nov 9, 2008, 8:02:07 AM11/9/08
to Google App Engine
Can you post example code?

On Nov 9, 1:28 am, Alexander Kojevnikov <alexan...@kojevnikov.com>
wrote:

Alexander Kojevnikov

unread,
Nov 9, 2008, 7:51:54 PM11/9/08
to Google App Engine
> Can you post example code?

Sure. Below is an xml template that generates the blog feed.
updated_feed and updated_entry are custom filters that return the date
in the right format.

{% load filters %}{% autoescape off %}<?xml version="1.0"
encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">Muspy - Blog</title>
<link href="{{ url }}" rel="self" type="application/atom+xml" />
<link href="{{ root }}" rel="alternate" type="text/html" />
<id>{{ url }}</id>
<updated>{{ posts|updated_feed }}</updated>
<author><name>Muspy</name></author>
<icon>{{ root }}favicon.ico</icon>
<logo>{{ root }}static/logo.gif</logo>
{% for post in posts %}
<entry>
<title type="text"><![CDATA[{{ post.title }}]]></title>
<link href="{{ root }}{{ post.slug }}"/>
<id>{{ root }}{{ post.slug }}</id>
<updated>{{ post|updated_entry }}</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
{% autoescape on %}{% include post.template_name %}{% endautoescape %}
</div>
</content>
</entry>
{% endfor %}
</feed>{% endautoescape %}

jago

unread,
Nov 10, 2008, 12:09:28 AM11/10/08
to Google App Engine
Thanks!

On Nov 10, 1:51 am, Alexander Kojevnikov <alexan...@kojevnikov.com>
wrote:
Reply all
Reply to author
Forward
0 new messages