Esempio n. 1
0
from datetime import date, datetime, time
from time import strptime

from django.core.urlresolvers import reverse
from django.db.models import signals

from pingback import create_ping_func
from pingback.client import ping_external_links, ping_directories
from django_xmlrpc import xmlrpcdispatcher

from blogango.models import BlogEntry

def pingback_blog_handler(year, month, slug, **kwargs):
    return BlogEntry.objects.get(created_on__year=year, 
                                 created_on__month=month, 
                                 slug=slug, 
                                 is_published=True)
    

ping_details = {'blogango_details': pingback_blog_handler}

ping_func = create_ping_func(**ping_details)

xmlrpcdispatcher.register_function(ping_func, 'pingback.ping')

signals.post_save.connect(ping_external_links(content_attr='text', url_attr='get_absolute_url'), sender=BlogEntry, weak=False)

Esempio n. 2
0
            self.get_absolute_url(), _('view'))

    view_link.allow_tags = True


# Pingback and directory ping handling
def pingback_blog_handler(year, month, day, slug, **kwargs):
    from datetime import time, date, datetime
    from time import strptime
    d = date(*strptime(year + month + day, '%Y%m%d')[:3])
    r = (datetime.combine(d, time.min), datetime.combine(d, time.max))
    return Post.objects.filter(date__range=r).get(slug=slug)


ping_details = {'post_detail': pingback_blog_handler}
xmlrpc.dispatcher.register_function(create_ping_func(**ping_details),
                                    'pingback.ping')

ping_links = ping_external_links(content_attr='html',
                                 url_attr='get_absolute_uri',
                                 filtr=lambda x: not x.is_draft)
ping_dirs = ping_directories(content_attr='html',
                             url_attr='get_absolute_uri',
                             filtr=lambda x: not x.is_draft)

if appcheck.pingback:
    signals.post_save(sender=Post)(ping_links)
    signals.post_save(sender=Post)(ping_dirs)

if appcheck.watchlist:
    from watchlist.models import Subscription
Esempio n. 3
0
        return u'<a href="%s://%s%s">%s</a>' % (
            settings.SITE_PROTOCOL, self.site.domain,
            self.get_absolute_url(), _('view'))
    view_link.allow_tags = True


# Pingback and directory ping handling
def pingback_blog_handler(year, month, day, slug, **kwargs):
    from datetime import time, date, datetime
    from time import strptime
    d = date(*strptime(year + month + day, '%Y%m%d')[:3])
    r = (datetime.combine(d, time.min), datetime.combine(d, time.max))
    return Post.objects.filter(date__range=r).get(slug=slug)

ping_details = {'post_detail': pingback_blog_handler}
xmlrpc.dispatcher.register_function(create_ping_func(**ping_details), 'pingback.ping')


ping_links = ping_external_links(content_attr='html', url_attr='get_absolute_uri',
                                 filtr=lambda x: not x.is_draft)
ping_dirs = ping_directories(content_attr='html', url_attr='get_absolute_uri',
                             filtr=lambda x: not x.is_draft)

if appcheck.pingback:
    signals.post_save(sender=Post)(ping_links)
    signals.post_save(sender=Post)(ping_dirs)


if appcheck.watchlist:
    from watchlist.models import Subscription
    @signals.post_save(sender=Post)