Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there any Generic RSS/ATOM generator in Python?

5 views
Skip to first unread message

js

unread,
Feb 11, 2008, 9:47:56 AM2/11/08
to pytho...@python.org
Hi,

I'm looking for RSS/ATOM generator I can use in Python.
I searched on pypi and the other places but I couldn't find any
options on this. (I found many parsers, though)
Is there any de-fact standard RSS/ATOM generator? (especially, I'd
like to create Atom's)
Do I have to do it myself from scratch?

Thanks in advance.

Stefan Behnel

unread,
Feb 11, 2008, 10:24:41 AM2/11/08
to js

Try googling for "python atom", gives me this as first hit:

http://www.imc.org/atom-syntax/mail-archive/msg18662.html

But since it's not that hard to generate XML in general, maybe these are also
worth another look:

http://blog.ianbicking.org/2007/08/02/atom-models/
http://codespeak.net/lxml/objectify.html#tree-generation-with-the-e-factory

Stefan

Terran Melconian

unread,
Feb 14, 2008, 2:00:03 AM2/14/08
to
On 2008-02-11, js <ebg...@gmail.com> wrote:
> Is there any de-fact standard RSS/ATOM generator? (especially, I'd
> like to create Atom's)
> Do I have to do it myself from scratch?

I looked into similar issues about six months ago. My conclusion was
that generally XML generation libraries (unlike parsers) don't get
written, because there's little enough to them that it isn't seen as
worth doing, and that accepted practice is to just do it yourself.

Torsten Bronger

unread,
Feb 14, 2008, 2:27:35 AM2/14/08
to
Hallöchen!

Terran Melconian writes:

Maybe I understand you wrongly but there *is* a general XML
generator with ElementTree. I wouldn't generate XML directly but
using ElementTree to generate Atom. I did it myself three months
ago and it was really trivial.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: bro...@jabber.org
(See http://ime.webhop.org for further contact info.)

Stefan Behnel

unread,
Feb 14, 2008, 2:41:51 AM2/14/08
to Torsten Bronger
Torsten Bronger wrote:
> Terran Melconian writes:
>
>> On 2008-02-11, js <ebg...@gmail.com> wrote:
>>
>>> Is there any de-fact standard RSS/ATOM generator? (especially,
>>> I'd like to create Atom's) Do I have to do it myself from
>>> scratch?
>> I looked into similar issues about six months ago. My conclusion
>> was that generally XML generation libraries (unlike parsers) don't
>> get written, because there's little enough to them that it isn't
>> seen as worth doing, and that accepted practice is to just do it
>> yourself.
>
> Maybe I understand you wrongly but there *is* a general XML
> generator with ElementTree. I wouldn't generate XML directly but
> using ElementTree to generate Atom. I did it myself three months
> ago and it was really trivial.

Actually, there's tons of XML generator packages (most of them single Python
modules), ElementTree itself and the "E factory" being only two of them.

Stefan

Canarix

unread,
Feb 14, 2008, 2:51:28 AM2/14/08
to pytho...@python.org
Hi,

On Mon, Feb 11, 2008 at 3:47 PM, js <ebg...@gmail.com> wrote:
> Hi,


>
> I'm looking for RSS/ATOM generator I can use in Python.
> I searched on pypi and the other places but I couldn't find any
> options on this. (I found many parsers, though)

> Is there any de-fact standard RSS/ATOM generator? (especially, I'd
> like to create Atom's)
> Do I have to do it myself from scratch?

You can look at PyRSS2Gen which works fine for me :
http://www.dalkescientific.com/Python/PyRSS2Gen.html

But it only works with RSS2.

Bye,
CanariX

>
> Thanks in advance.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Torsten Bronger

unread,
Feb 14, 2008, 2:57:49 AM2/14/08
to
Hallöchen!

Stefan Behnel writes:

> Torsten Bronger wrote:
>
>> Terran Melconian writes:
>>

>> [...]


>>
>> Maybe I understand you wrongly but there *is* a general XML
>> generator with ElementTree. I wouldn't generate XML directly but
>> using ElementTree to generate Atom. I did it myself three months
>> ago and it was really trivial.
>
> Actually, there's tons of XML generator packages (most of them
> single Python modules), ElementTree itself and the "E factory"
> being only two of them.

I mentioned ElementTree because in my opinion, it is the only sane
XML generator in the standard lib.

js

unread,
Feb 14, 2008, 7:33:53 AM2/14/08
to Torsten Bronger, pytho...@python.org

Torsten Bronger

unread,
Feb 14, 2008, 7:59:01 AM2/14/08
to
Hallöchen!

js writes:

Excerpt from my code:

root = ElementTree.Element("feed", xmlns="http://www.w3.org/2005/Atom")
ElementTree.SubElement(root, "id").text = self.id
ElementTree.SubElement(root, "title").text = self.title
ElementTree.SubElement(root, "updated").text = format_time(self.updated)

Stefan Behnel

unread,
Feb 14, 2008, 8:21:37 AM2/14/08
to Torsten Bronger
Torsten Bronger wrote:
> js writes:
>
>> Trivial?
>> More than XML::Atom::Feed?
>> http://search.cpan.org/~miyagawa/XML-Atom-0.28/lib/XML/Atom/Feed.pm
>
> Excerpt from my code:
>
> root = ElementTree.Element("feed", xmlns="http://www.w3.org/2005/Atom")
> ElementTree.SubElement(root, "id").text = self.id
> ElementTree.SubElement(root, "title").text = self.title
> ElementTree.SubElement(root, "updated").text = format_time(self.updated)

Look at the bottom of this page for an RSS example using the "E factory":

http://effbot.org/zone/element-builder.htm

I find it much more readable than the above code, especially if you use the
version that comes with lxml.objectify, which has better support for
namespaces and data types:

http://codespeak.net/lxml/objectify.html#tree-generation-with-the-e-factory

Stefan

Torsten Bronger

unread,
Feb 14, 2008, 8:31:46 AM2/14/08
to
Hallöchen!

Stefan Behnel writes:

> Torsten Bronger wrote:
>
>> [...]


>>
>> Excerpt from my code:
>>
>> root = ElementTree.Element("feed", xmlns="http://www.w3.org/2005/Atom")
>> ElementTree.SubElement(root, "id").text = self.id
>> ElementTree.SubElement(root, "title").text = self.title
>> ElementTree.SubElement(root, "updated").text = format_time(self.updated)
>
> Look at the bottom of this page for an RSS example using the "E factory":
>
> http://effbot.org/zone/element-builder.htm
>
> I find it much more readable than the above code, especially if you use the
> version that comes with lxml.objectify, which has better support for
> namespaces and data types:
>
> http://codespeak.net/lxml/objectify.html#tree-generation-with-the-e-factory

If you have more complex tasks, all this may be true; however,
generating Atom is just *so* simple that I prefer the version which
works without tweaking and further dependencies.

Stefan Behnel

unread,
Feb 14, 2008, 8:50:58 AM2/14/08
to Torsten Bronger
Torsten Bronger wrote:
> Stefan Behnel writes:
>
>> Torsten Bronger wrote:
>>
>>> [...]
>>>
>>> Excerpt from my code:
>>>
>>> root = ElementTree.Element("feed", xmlns="http://www.w3.org/2005/Atom")
>>> ElementTree.SubElement(root, "id").text = self.id
>>> ElementTree.SubElement(root, "title").text = self.title
>>> ElementTree.SubElement(root, "updated").text = format_time(self.updated)
>>
>> Look at the bottom of this page for an RSS example using the "E factory":
>>
>> http://effbot.org/zone/element-builder.htm
[...]

> If you have more complex tasks, all this may be true; however,
> generating Atom is just *so* simple that I prefer the version which
> works without tweaking and further dependencies.

The E factory is a small module with one main class. Adding that to your code
base doesn't give you any dependencies...

Stefan

Torsten Bronger

unread,
Feb 14, 2008, 9:00:57 AM2/14/08
to
Hallöchen!

Stefan Behnel writes:

> [...]


>
> The E factory is a small module with one main class. Adding that
> to your code base doesn't give you any dependencies...

Yes, but just for creating five elements? ;-)

js

unread,
Feb 14, 2008, 8:59:32 AM2/14/08
to Stefan Behnel, pytho...@python.org
Great...
I guess I should have learned more about ElementTree.
In anyway, Thanks all. You all convinced me, really.

> --
> http://mail.python.org/mailman/listinfo/python-list
>

Christopher Arndt

unread,
Feb 18, 2008, 5:12:29 PM2/18/08
to

You didn't specify your use case very much. If you just want to add
support for generating Atom/RSS feeds to your app and the format (i.e.
which elements and attributes are used) isn't too dynamic, you could
just an XML-templating language like Kid or Genshi.

The feed generator included in TurboGears uses this approach. I
recently packaged this as a separate module:

http://chrisarndt.de/projects/turbofeeds/

The module still only makes sense in a TurboGears context but you may
want to look at the Kid templates used, they could be used by any app
that wants to generate Atom/RSS:

http://trac.turbogears.org/browser/projects/TurboFeeds/trunk/turbofeeds/templates

Chris

0 new messages