Permalink
Browse files

Fixed some bugs.

  • Loading branch information...
1 parent 23eb449 commit 828b71a6ae2e14bcb3a0daf620feaa3d750368e1 @bmc committed Aug 25, 2008
Showing with 36 additions and 56 deletions.
  1. +33 −2 admin.py
  2. +2 −2 index.yaml
  3. +1 −52 technorati.py → xmlrpc.py
View
@@ -7,13 +7,24 @@
import cgi
import logging
+import xmlrpc
+import xmlrpclib
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
+from google.appengine.api import urlfetch
from models import *
import request
+import defs
+
+# -----------------------------------------------------------------------------
+# Constants
+# -----------------------------------------------------------------------------
+
+TECHNORATI_PING_RPC_URL = 'http://rpc.technorati.com/rpc/ping'
+FAKE_TECHNORATI_PING_RPC_URL = 'http://localhost/~bmc/technorati-mock/'
# -----------------------------------------------------------------------------
# Classes
@@ -126,10 +137,30 @@ def get(self):
# Functions
# -----------------------------------------------------------------------------
+def ping_technorati():
+ if defs.ON_GAE:
+ url = TECHNORATI_PING_RPC_URL
+ else:
+ url = FAKE_TECHNORATI_PING_RPC_URL
+
+ logging.debug('Pinging Technorati at: %s' % url)
+ try:
+ transport = xmlrpc.GoogleXMLRPCTransport()
+ rpc_server = xmlrpclib.ServerProxy(url, transport=transport)
+ result = rpc_server.weblogUpdates.ping(defs.BLOG_NAME,
+ defs.CANONICAL_BLOG_URL)
+ if result.get('flerror', False) == True:
+ logging.error('Technorati ping error from server: %s' %
+ result.get('message', '(No message in RPC result)'))
+ else:
+ logging.debug('Technorati ping successful.')
+ except:
+ raise urlfetch.DownloadError, \
+ "Can't ping Technorati: %s" % sys.exc_info()[1]
+
def alert_the_media():
# Right now, we only alert Technorati
- import technorati
- technorati.ping_technorati()
+ ping_technorati()
# -----------------------------------------------------------------------------
# Main program
View
@@ -10,14 +10,14 @@ indexes:
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
-# Used 6 times in query history.
+# Used 17 times in query history.
- kind: Article
properties:
- name: draft
- name: published_when
direction: desc
-# Used 2 times in query history.
+# Used 6 times in query history.
- kind: Article
properties:
- name: published_when
@@ -16,27 +16,6 @@
from google.appengine.api import urlfetch
-import defs
-
-# -----------------------------------------------------------------------------
-# Constants
-# -----------------------------------------------------------------------------
-
-TECHNORATI_PING_RPC_URL = 'http://rpc.technorati.com/rpc/ping'
-FAKE_TECHNORATI_PING_RPC_URL = 'http://localhost/~bmc/technorati-mock/'
-
-# -----------------------------------------------------------------------------
-# Classes
-# -----------------------------------------------------------------------------
-
-class TechnoratiPingError(Exception):
-
- def __init__(self, msg):
- self.msg = msg
-
- def __str__(self):
- return msg
-
# -----------------------------------------------------------------------------
# Classes
# -----------------------------------------------------------------------------
@@ -94,36 +73,6 @@ def request(self, host, handler, request_body, verbose=0):
return result
def __parse_response(self, response_body):
- p, u = xmlrpclib.getparser(use_datetime=self._use_datetime)
+ p, u = xmlrpclib.getparser(use_datetime=0)
p.feed(response_body)
return u.close()
-
-# -----------------------------------------------------------------------------
-# Functions
-# -----------------------------------------------------------------------------
-
-def ping_technorati():
- if defs.ON_GAE:
- url = TECHNORATI_PING_RPC_URL
- else:
- url = FAKE_TECHNORATI_PING_RPC_URL
-
- logging.debug('Pinging Technorati at: %s' % url)
- try:
- rpc_server = xmlrpclib.ServerProxy(url,
- transport=GoogleXMLRPCTransport())
- except:
- raise TechnoratiPingError("Can't ping Technorati: %s" %
- sys.exc_info()[1])
-
- try:
- result = rpc_server.weblogUpdates.ping(defs.BLOG_NAME,
- defs.CANONICAL_BLOG_URL)
- if result.get('flerror', False) == True:
- logging.error('Technorati ping error from server: %s' %
- result.get('message', '(No message in RPC result)'))
- else:
- logging.debug('Technorati ping successful.')
- except:
- raise TechnoratiPingError("Can't ping Technorati: %s" %
- sys.exc_info()[1])

0 comments on commit 828b71a

Please sign in to comment.