Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ping FeedBurner in Django App

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?

like image 696
Apreche Avatar asked Dec 08 '22 07:12

Apreche


1 Answers

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.

like image 105
tghw Avatar answered Jan 03 '23 15:01

tghw