Announcing atomfeed.py, xmlelements.py, and feedutils.py

Discussion in 'Python' started by Steve R. Hastings, Mar 8, 2006.

  1. I have written some Python library modules to help with creating Atom
    syndication feeds. Originally, I had a single module called "PyAtom"; now
    I have split it up into three modules: xmlelements.py, atomfeed.py, and
    feedutils.py.

    You can download these modules from here:

    http://home.blarg.net/~steveha/atomfeed-0.5.0.tar.gz



    I wrote these because I wanted a really easy, Pythonic way to create Atom
    syndication feeds. Here is a bit of sample code from the self-test at the
    end of atomfeed.py:

    -- cut here -- cut here -- cut here -- cut here -- cut here --
    # Test: generate the "Atom-Powered Robots Run Amok" example
    #
    # Note: the original had some of the XML declarations in
    # a different order than atomfeed puts them. I swapped around
    # the lines here so they would match the atomfeed order. Other
    # than that, this is the example from:
    #
    # http://www.atomenabled.org/developers/syndication/#sampleFeed

    s_example = """\
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
    <title>Example Feed</title>
    <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
    <updated>2003-12-13T18:30:02Z</updated>
    <author>
    <name>John Doe</name>
    </author>
    <link href="http://example.org/"/>
    <entry>
    <title>Atom-Powered Robots Run Amok</title>
    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
    <updated>2003-12-13T18:30:02Z</updated>
    <link href="http://example.org/2003/12/13/atom03"/>
    <summary>Some text.</summary>
    </entry>
    </feed>"""

    xmldoc, feed = new_xmldoc_feed()

    feed.title = "Example Feed"
    feed.id = "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
    feed.updated = "2003-12-13T18:30:02Z"

    link = Link("http://example.org/")
    feed.links.append(link)

    author = Author("John Doe")
    feed.authors.append(author)


    entry = Entry()
    feed.entries.append(entry)
    entry.id = "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"
    entry.title = "Atom-Powered Robots Run Amok"
    entry.updated = "2003-12-13T18:30:02Z"
    entry.summary = "Some text."

    link = Link("http://example.org/2003/12/13/atom03")
    entry.links.append(link)


    s = str(xmldoc)
    if s_example != s:
    failed_tests += 1
    print "test case failed:"
    print "The generated XML doesn't match the example. diff follows:"
    print diff(s_example, s)
    -- cut here -- cut here -- cut here -- cut here -- cut here --


    I welcome any feedback on these.
    --
    Steve R. Hastings "Vita est"
    http://www.blarg.net/~steveha
    Steve R. Hastings, Mar 8, 2006
    #1
    1. Advertising

  2. Steve R. Hastings

    Guest

    Steve R. Hastings wrote:
    > I have written some Python library modules to help with creating Atom
    > syndication feeds. Originally, I had a single module called "PyAtom"; now
    > I have split it up into three modules: xmlelements.py, atomfeed.py, and
    > feedutils.py.


    FWIW, see also Sylvain Hellegouarch's atomixlib [1]. It's used in
    production to generate and manage PlanetAtom [2][3].

    [1] http://trac.defuze.org/browser/oss/atomixlib
    [2] http://planetatom.net/
    [3] http://copia.ogbuji.net/blog/2006-01-25/Planet_Ato

    --
    Uche Ogbuji Fourthought, Inc.
    http://uche.ogbuji.net http://fourthought.com
    http://copia.ogbuji.net http://4Suite.org
    Articles: http://uche.ogbuji.net/tech/publications/
    , Mar 17, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter L.
    Replies:
    0
    Views:
    312
    Peter L.
    Oct 20, 2003
  2. P. Flavin
    Replies:
    0
    Views:
    487
    P. Flavin
    Nov 3, 2003
  3. Mark Hahn
    Replies:
    22
    Views:
    631
    Carlos Ribeiro
    Sep 9, 2004
  4. Steve R. Hastings
    Replies:
    0
    Views:
    298
    Steve R. Hastings
    Mar 24, 2006
  5. Mike Kent
    Replies:
    4
    Views:
    100
    Steve
    Jun 1, 2007
Loading...

Share This Page