2

我正在为我的 Blogger 博客使用Django-PuSH (PubSubHubPub)。

现在,我阅读了文档并可以编写简单的代码。但是,文档中从来没有提到任何地方输入回调 URL!

这是简单的代码。

# hubserver.py
@receiver(updated)
def listener(notification, **kwargs):
    e = []
    for entry in notification.entries:
        e.append(entry.title)

    for link in e:
        db = entries( url = link )
        db.save(force_insert=True)


from django.shortcuts import render_to_response
from django_push.subscriber.models import Subscription
from models import mydata

# views
def bloghub (request):
    subscription = Subscription.objects.subscribe("http://myblog.blogspot.in//feeds/posts/default",
                                                  "http://pubsubhubbub.appspot.com")
    db = mydata.objects.all()
    lis = [i.url for i in db]
    context = {"lis" : lis}
    return render_to_response("home.html", context)


  [1]: http://django-push.readthedocs.org

# urls.py
urlpatterns = patterns('',
                       url(r'^$', views.bloghub ),
                       url(r'^subscriber/', include('django_push.subscriber.urls')),

)
4

0 回答 0