def watch(self, realm, resid, user, lastvisit=0, db=None): """Adds given resources to watchlist. They must not be watched already.""" db = db or self.env.get_db_cnx() cursor = db.cursor() cursor.executemany(""" INSERT INTO watchlist (wluser, realm, resid, lastvisit) VALUES (%s,%s,%s,%s) """, [(user, realm, res, lastvisit) for res in ensure_iter(resid)])
def unwatch(self, realm, resid, user, db=None): db = db or self.env.get_db_cnx() cursor = db.cursor() cursor.log = self.log self.log.debug("resid = " + unicode(resid)) reses = list(ensure_iter(resid)) cursor.execute(""" DELETE FROM watchlist WHERE wluser=%s AND realm=%s AND resid IN ( """ + ",".join(("%s",) * len(reses)) + ")", [user,realm] + reses)
def unwatch(self, realm, resid, user, db=None): db = db or self.env.get_db_cnx() cursor = db.cursor() cursor.log = self.log self.log.debug("resid = " + unicode(resid)) reses = list(ensure_iter(resid)) cursor.execute( """ DELETE FROM watchlist WHERE wluser=%s AND realm=%s AND resid IN ( """ + ",".join(("%s", ) * len(reses)) + ")", [user, realm] + reses)