The Artima Developer Community
Sponsored Link

Python Buzz Forum
How do you send blog posts with complicated RSS over the metaWeblog API?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Phillip Pearson

Posts: 1083
Nickname: myelin
Registered: Aug, 2003

Phillip Pearson is a Python hacker from New Zealand
How do you send blog posts with complicated RSS over the metaWeblog API? Posted: Oct 1, 2003 12:11 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Phillip Pearson.
Original Post: How do you send blog posts with complicated RSS over the metaWeblog API?
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Latest Python Buzz Posts
Latest Python Buzz Posts by Phillip Pearson
Latest Posts From Second p0st

Advertisement

An item in an RSS 2.0 feed looks like this:

<item>
    <title>title</title>
    <link>http://example.com/path/to/post</link>
    <guid>http://example.com/path/to/post</guid>
    <description>an rss2 item looks like this:
 
&lt;item&gt;
&nbsp;&nbsp;&nbsp; &lt;title&gt;title&lt;/title&gt;...</description>
</item>

title, link, guid and description are all part of the spec.  You can put in other things if you like, as long as you put them in a namespace.  Say, if you want to categorise this item under the Topic Exchange's Software channel, you could say that this way:

<item xmlns:ent="http://purl.org/NET/ENT/1.0/">
    <title>title</title>
    <link>http://example.com/path/to/post</link>
    <guid>http://example.com/path/to/post</guid>
    <description>an rss2 item looks like this:
 
&lt;item&gt;
&nbsp;&nbsp;&nbsp; &lt;title&gt;title&lt;/title&gt;...</description>
    <ent:cloud ent:href="http://topicexchange.com/topics">
        <ent:topic ent:id="software" ent:href="http://topicexchange.com/t/software/">software</ent:topic>
    </ent:cloud>
</item>

ent:cloud and ent:topic, as well as the attributes ent:href and ent:id are all defined in the ENT spec.

If you wanted to make this item into a book review, still in the same channel, you could say it like this.

<item xmlns:ent="http://purl.org/NET/ENT/1.0/" xmlns:rvw="http://purl.org/NET/RVW/0.1/">
    <title>title</title>
    <link>http://example.com/path/to/post</link>
    <guid>http://example.com/path/to/post</guid>
    <description>an rss2 item looks like this:
 
&lt;item&gt;
&nbsp;&nbsp;&nbsp; &lt;title&gt;title&lt;/title&gt;...</description>
    <ent:cloud ent:href="http://topicexchange.com/topics">
        <ent:topic ent:id="software" ent:href="http://topicexchange.com/t/software/">software</ent:topic>
    </ent:cloud>
    <rvw:item>
        <rvw:link>http://www.amazon.com/exec/obidos/ASIN/0156027321/</rvw:link>
        <dc:identifier>ASIN:0156027321</dc:identifier>
        <dc:type>Text</dc:type>
        <dc:title>Life of Pi</dc:title>
        <dc:creator>Yann Martel</dc:creator>
        <dc:publisher>Harvest Books</dc:publisher>
        <dc:date>2003-05</dc:date>
        <ent:cloud ent:href="http://www.pmbrowser.info/rvw/">
            <ent:topic ent:href="http://www.pmbrowser.info/rvw/types.xtm#book" ent:id="book">Book</ent:topic>  
        </ent:cloud>
        <rvw:rating>
            <rvw:minimum>0</rvw:minimum>
            <rvw:maximum>10</rvw:maximum>
        <rvw:value>7</rvw:value>
        </rvw:rating>
    </rvw:item>
</item>

All the rvw elements are defined in the RVW spec.

Now, if you want to post something like this to a weblog, what are your options?  Basically, you can use the metaWeblog API or make up your own one.  If you use the existing API, you will be compatible with many existing blogging tools, and if you make up your own one, you won't.

In Python, the call to post a normal blog post looks like this:

import xmlrpclib
s = xmlrpclib.Server('http://127.0.0.1:5335/RPC2')
s.metaWeblog.newPost(BLOGID, LOGIN, PASSWORD, {
    'title': TITLE,
    'link': LINK,
    'description': DESCRIPTION,
})

BLOGID, for Radio, is 'home'.  LOGIN and PASSWORD are the values you configure hereTITLE, LINK and DESCRIPTION are the values that show in the title, link and description elements in the resulting RSS.

If you want to include the ENT classification, it gets a bit trickier.  I think this is how it should work:

s.metaWeblog.newPost(BLOGID, LOGIN, PASSWORD, {
    'title': TITLE,
    'link': LINK,
    'description': DESCRIPTION,
    'http://purl.org/NET/ENT/1.0/': {
        'cloud': {
            'href': "http://www.pmbrowser.info/rvw/",
            '_value': {
                'topic': {
                    'href': "http://www.pmbrowser.info/rvw/types.xtm#book",
                    'id': "book",
                    '_value': "Book",
                },
            },
        },

    },
})

I've never seen any code using this, but there are hooks in Radio (see radio.weblog.metaWeblog.* and weblogData.callbacks.*) for plugins to handle extra values, so it's likely that someone is using it somewhere.  The spec isn't clear as to whether namespaces have to be re-specified for attributes (e.g. the ent:href under the ent:cloud) or sub-elements (e.g. the ent:topic under the ent:cloud), so this looks a little weird.

Does anybody know of any real-life examples of this sort of thing?  I'd be very interested to hear from you, as I'm not at all sure if I got the above example correct.

Comment

Read: How do you send blog posts with complicated RSS over the metaWeblog API?

Topic: Tonight's Star Party Previous Topic   Next Topic Topic: Pyzine revival

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use