SELECT id, site_id, title, link, entry_id, added, published, updated, summary, content, display_cache FROM site_history where site_id = %s
"""
print(" getting current entries for %d" % self.site_id)
- d = self.dcm.runQuery(q, self.site_id)
+ d = self.dcm.runQuery(q, [ self.site_id ])
d.addCallback(self.gotEntries)
d.addErrback(self.error)
# If new_site is in the state, we're adding a new site so set
# the flag so that we know these sites were added when the
# site was first added.
- on_new = 0
+ on_new = False
if self.state.has_key("new_site"):
- on_new = 1
+ on_new = True
t = datetime.utcnow()
def insertInteraction(self, trans, *args):
trans.execute(*args)
- return trans.lastrowid
+ trans.execute("SELECT CURRVAL('site_history_id_seq')")
+ return trans.fetchone()[0]
def maybeUpdateEntry(self, entry, old_entry):
published = None
q = "UPDATE site set " + update + "feed_type = %s, title = %s, last_poll = %s WHERE id = %s"
args.extend([self.feed["version"], self.feed["title"], datetime.utcnow(), self.site_id])
- d = self.dcm.runQuery(q, args);
+ d = self.dcm.runInteraction(self.newInteraction, q, args);
d.addCallback(self.done)
d.addErrback(self.error)
+ def newInteraction(self, trans, *args):
+ trans.execute(*args)
+
def done(self, *args):
print(" done.")
self.state["site_history_new_ids"] = self.insert_ids
SELECT person_id, url, status, data, track_info FROM new_site WHERE id = %s
"""
- d = self.dcm.runQuery(q, self.id)
+ d = self.dcm.runQuery(q, [ self.id ])
d.addCallback(self.gotNewSite)
d.addErrback(self.error)
def newSiteInteraction(self, trans, *args):
trans.execute(*args)
- return trans.lastrowid
+ trans.execute("SELECT CURRVAL('site_id_seq')")
+ return trans.fetchone()[0]
def siteSetupDone(self, results):
self.state["site_id"] = results
referer=ti.get("referer", None)
follower=ti.get("follower", None)
- d = self.dcm.runQuery(q, (t, "add", "site", state["site_id"], follower, referer, remoteip, useragent))
+ d = self.dcm.runInteraction(self.newInteraction, q, (t, "add", "site", state["site_id"], follower, referer, remoteip, useragent))
d.addCallback(self.done)
d.addErrback(self.error)
return self.d
+ def newInteraction(self, trans, *args):
+ trans.execute(*args)
+ trans.execute("SELECT CURRVAL('change_audit_id_seq')")
+ return trans.fetchone()[0]
+
def done(self, *args, **kw):
self.d.callback(None)
q = """
UPDATE new_site SET status = 'done', site_id = %s where id = %s
"""
- d = self.dcm.runQuery(q, (state["site_id"], state["id"]))
+ d = self.dcm.runInteraction(self.newSiteInteraction, q, (state["site_id"], state["id"]))
+
d.addCallback(self.done)
d.addErrback(self.error)
return self.d
- def done(self, *args, **kw):
+ def newSiteInteraction(self, trans, *args):
+ trans.execute(*args)
+ return trans.lastrowid
+
+ def done(self, result, *args, **kw):
site_history_new_ids = self.state.get("site_history_new_ids", [])
self.d.callback(dict(site_id=self.state["site_id"],
site_history_new_ids=site_history_new_ids,
UPDATE new_site SET status = 'pick_url', data = %s WHERE id = %s
"""
- d = self.dcm.runQuery(q, (data, id))
+ d = self.dcm.runInteraction(self.newInteraction, q, (data, id))
d.addCallback(self.updateDone)
else:
else:
error = "internal"
- d = self.dcm.runQuery(q, (error, id))
+ d = self.dcm.runInteraction(self.newInteraction, q, (error, id))
d.addCallback(self.updateDoneError)
return self.d
+ def newInteraction(self, trans, *args):
+ trans.execute(*args)
+ return trans.lastrowid
+
def updateDoneError(self, *args, **kw):
self.d.errback(self.orig_failure)
- def updateDone(self, *args, **kw):
+ def updateDone(self, result, *args, **kw):
self.d.callback(dict(site_id=None, type=None))