{ "info": { "author": "Alexander Solovyov", "author_email": "piranha@piranha.org.ua", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Plugins", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. -*- mode: rst -*-\n\n=================\n django-pingback\n=================\n\nThis two applications provide 3 connected services: pingback server,\npingback client and directory ping client.\n\nDepends on the `django-xmlrpc`_.\n\nConfiguration\n-------------\n\nFirst, install the `django-xmlrpc`_ application. You can download it\neither from `repo`_ or just use setuptools::\n\n easy_install -Z -f http://pypi.aartemenko.com django-xmlrpc\n\nNext, download and install ``django-pingback``:\n\n * download sources from main `repository`_\n * or use ``easy_install django-pingback``\n * add ``pingback`` to your ``INSTALLED_APPS``\n * run ``./manage.py syncdb``\n * setup client and server callbacks.\n\n.. _repo: django-xmlrpc_\n.. _repository: django-pingback_\n\nConnecting server\n-----------------\n\nPingback server receives pings from other sites, so, we must create\nfunction which binds our URLs an objects.\n\nBut first of all, add this urlpattern to your urls configuration::\n\n ((r'^xmlrpc/$', 'django_xmlrpc.views.handle_xmlrpc', {}, 'xmlrpc'))\n\nIt is a handler for all xmlrpc requests.\n\nUsually, blog has a detailed view for each post. Suppose that our view\nresides in ``blog.views.post_detail`` and accepts one keyword arguments ``slug``.\n\nHere is simple example, how to make ``Post`` objects pingable::\n\n from datetime import time, date, datetime\n from time import strptime\n\n from blog.models import Post\n from pingback import register_pingback, ping_func\n from django_xmlrpc import xmlrpcdispatcher\n\n # create simple function which returns Post object and accepts\n # exactly same arguments as 'details' view.\n def pingback_blog_handler(slug, **kwargs):\n return Post.objects.get(slug=slug)\n\n # register pingback on our post_detail\n register_pingback('blog.views.post_detail', pingback_blog_handler)\n\n # register pingback handler in the dispatcher\n xmlrpcdispatcher.register_function(ping_func, 'pingback.ping')\n\n.. note::\n\n If you are using middleware (described later), you don't need to register\n ping_func in xmlrpc dispatcher, it's done automatically.\n\nNow, go at you http://mysweetsite.com/xmlrpc/ and you should see\n``pingback.ping`` method among few other system methods. If it is not\nthere, then you made mistake in you server setup.\n\nAlso, you need to tell other sites, that your blog accepts\npingbacks. You can do it by adding a link in the head of your site::\n\n \n\nOr by adding X-Pingback HTTP header. Do do this, just add such line in\nthe ``settings.py``::\n\n MIDDLEWARE_CLASSES = [\n # ...\n 'pingback.middleware.PingbackMiddleware',\n ]\n\nConnecting client signals\n-------------------------\n\nLet's suppose, that you have a blog and want to ping external sites\n(like Technorati) on post save, and to receive pingbacks from other\nsites. Next two sections contain simple 'how-to' enable these features.\n\nAt first, setup configuration in the settings, here is an example::\n\n DIRECTORY_URLS = (\n 'http://ping.blogs.yandex.ru/RPC2',\n 'http://rpc.technorati.com/rpc/ping',\n )\n\n\nNext, you must connect some signals to ping workers, which created using\n``ping_external_links`` and ``ping_directories`` functions::\n\n from django.db.models import signals\n from pingback.client import ping_external_links, ping_directories\n from blog.models import Post\n\n signals.post_save.connect(\n ping_external_links(content_attr = 'html',\n url_attr = 'get_absolute_url'),\n sender=Post, weak=False)\n\n signals.post_save.connect(\n ping_directories(url_attr = 'get_absolute_url'),\n sender=Post, weak=False)\n\nPlease note, that in the ``content_attr`` you must give either attribute\nor method name, which returns HTML content of the object.\n\nIf you don't have such attribute or method, for example if you apply\nmarkdown filter in the template, then ``content_func`` argument can be\nused instead of the ``content_attr``.\n\n``content_func`` must return HTML, and must accepts an instance as a\nsingle argument.\n\n.. note::\n\n Pay attention to the ``weak=False`` argument. If case of omitting Django event\n dispatcher will remove your signal.\n\n\nTemplate tags\n-------------\n\nTo show pingbacks on your page, you can use code like this::\n\n {% load pingback_tags %}\n {% get_pingback_list for object as pingbacks %}\n {% if pingbacks %}\n
{{ pingback.content }}
\n