Commits

Anonymous committed 480cd6a

ReFixed #11. Function renamed, more comprehensive.

--HG--
extra : convert_revision : svn%3Aea932676-bf3b-0410-9f11-03e9079df846/trunk%40172

Comments (0)

Files changed (2)

diario/signals.py

 from datetime import datetime
 from django.contrib.sites.models import Site
 from django.core.urlresolvers import reverse
-from diario.utils import markuping, pingomatic
+from diario.utils import markuping, ping_weblog_directory
 
 def convert_body_to_html(instance, **kwargs):
     """
     if created:
         site = Site.objects.get_current()
         site_url = 'http://%s' % site + reverse('diario-entry-list')
-        try:
-            pingomatic(site.name, site_url)
-        except:
-            pass
+        ping_weblog_directory(site.name, site_url, 'http://rpc.pingomatic.com/')
     else:
         return value            # raw
 
-def pingomatic(site_name, site_url, server_url='http://rpc.pingomatic.com/'):
+def ping_weblog_directory(site_name, site_url, server_url, fail_silently=True):
     """
-    Updates multiple services and search engines about updates to
-    weblog content, with `ping-o-matic <http://pingomatic.com/>`_.
+    Ping weblog directory about weblog updates. Works with Technorati,
+    ping-o-matic and others.
 
     *Required arguments:*
 
     * ``site_name``: name of site/weblog.
     * ``site_url``: site/weblog URL.
+    * ``server_url``: URL of XML-RPC server to ping.
 
     *Optional arguments:*
 
-    * ``server_url``: URL of ping-o-matic RPC server.
+    * ``fail_silently``: if true, don't raises any exception when ping fails.
 
+    Note: In signals module you have a signal to ping ping-o-matic.
     """
     server = ServerProxy(server_url)
-    return server.weblogUpdates.ping(site_name, site_url)
+    try:
+        return server.weblogUpdates.ping(site_name, site_url)
+    except Exception, e:
+        if fail_silently:
+            return
+        raise e
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.