views:

423

answers:

3

I have a django site, and some of the feeds are published through FeedBurner. I would like to ping FeedBurner whenever I save an instance of a particular model. FeedBurner's website says to use the XML-RPC ping mechanism, but I can't find a lot of documentation on how to implement it.

What's the easiest way to do the XML-RPC ping in django/Python?

+1  A: 

maybe sth like that:

import xmlrpclib
j = xmlrpclib.Server('http://feedburnerrpc')
reply = j.weblogUpdates.ping('website title','http://urltothenewpost')
zalew
+11  A: 

You can use Django's signals feature to get a callback after a model is saved:

import xmlrpclib
from django.db.models.signals import post_save
from app.models import MyModel

def ping_handler(sender, instance=None, **kwargs):
    if instance is None:
        return
    rpc = xmlrpclib.Server('http://ping.feedburner.google.com/')
    rpc.weblogUpdates.ping(instance.title, instance.get_absolute_url())

post_save.connect(ping_handler, sender=MyModel)

Clearly, you should update this with what works for your app and read up on signals in case you want a different event.

tghw
Just want to let people know that because Google acquired feedburner, the new URL is http://ping.feedburner.google.com.
Apreche
You have to add a slash at the end of the server URL, otherwise the RPC call will goes to ping.feedburner.google.com/RPC2 and get a 404 error.
Iamamac
@lamamac Added the slash. Thanks for catching that!
tghw
+2  A: 

Use pluggable apps, Luke!

http://github.com/svetlyak40wt/django-pingback/

Alexander Artemenko