+2008-11-27 Christopher Blizzard <blizzard@0xdeadbeef.com>
+
+ * tests/twisted/network/test_feedrefresh.py (TestFeedRefresh.confirmEntityHit):
+ Check to make sure we changed last_poll when we hit an etag or
+ last_modified.
+
+ * services/command/siterefresh.py (RefreshSiteError.handleError):
+ Update the last_poll field in the site table with the date if we
+ hit the etag or last_modified value.
+
2008-11-22 Christopher Blizzard <blizzard@0xdeadbeef.com>
* whoisi/test_controller.py (TestController.modified): Now returns
self.d = defer.Deferred()
def handleError(self, state, failure):
+ self.state = state
error = None
id = state["site_refresh_id"]
self.orig_failure = failure
self.it_failed = True
+ # a NotModifiedError is actually a success so we update the
+ # site_refresh table with "done" and then update the last_poll
+ # on the site table
if failure.check(NotModifiedError):
+ self.it_failed = False
q = """
- UPDATE site_refresh set status = "done", error = %s where id = %s
+ UPDATE site_refresh set status = "done", error = "http_not_modified" where id = %s
"""
- error = "http_not_modified"
- self.it_failed = False
+ d = self.dcm.runQuery(q, id)
+ d.addCallback(self.modifiedUpdateDone)
+ d.addErrback(self.updateFailed)
+ return self.d
- else:
+ q = """
+ UPDATE site_refresh SET status = "error", error = %s where id = %s
+ """
- q = """
- UPDATE site_refresh SET status = "error", error = %s where id = %s
- """
- error = str(failure)
+ error = str(failure)
d = self.dcm.runQuery(q, (error, id))
d.addCallback(self.updateDone)
+ d.addErrback(self.updateFailed)
return self.d
+ def modifiedUpdateDone(self, *args, **kw):
+ site_id = self.state["site_id"]
+ q = """
+ UPDATE site SET last_poll = %s WHERE id = %s
+ """
+ d = self.dcm.runQuery(q, (datetime.datetime.utcnow(), site_id))
+ d.addCallback(self.updateDone)
+ d.addErrback(self.updateFailed)
+
def updateDone(self, *args, **kw):
if self.it_failed:
self.d.errback(self.orig_failure)
# this makes the error handler return success
retval = dict(site_history_new_ids = [], http_entity_hit=1)
self.d.callback(retval)
+
+ def updateFailed(self, failure):
+ print(" failure in error handler: %s" % str(failure))
+ self.d.errback(failure)