X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Ftable.py;h=44d0b869709768a2d71563f0988e0daf78fda6ce;hb=b1775bb47ea5e242d337dbd34f5d58d10a57a028;hp=f6090a0391496a816ab97e5f1de9e3a563dd202b;hpb=0ff64f9d817f74fecab22be3ee4eb7538dc44ed6;p=sfa.git diff --git a/sfa/util/table.py b/sfa/util/table.py index f6090a03..44d0b869 100644 --- a/sfa/util/table.py +++ b/sfa/util/table.py @@ -5,13 +5,11 @@ # # TODO: Use existing PLC database methods? or keep this separate? -import report import pgdb from sfa.util.PostgreSQL import * from sfa.trust.gid import * from sfa.util.record import * -from sfa.util.debug import * from sfa.util.config import * from sfa.util.filter import * @@ -28,7 +26,7 @@ class SfaTable(list): if record_filter: records = self.find(record_filter) - for record in reocrds: + for record in records: self.append(record) def exists(self): @@ -88,16 +86,17 @@ class SfaTable(list): self.db.commit() def remove(self, record): - query_str = "DELETE FROM %s WHERE record_id = %s" % \ - (self.tablename, record['record_id']) - self.db.do(query_str) + params = {'record_id': record['record_id']} + template = "DELETE FROM %s " % self.tablename + sql = template + "WHERE record_id = %(record_id)s" + self.db.do(sql, params) # if this is a site, remove all records where 'authority' == the # site's hrn if record['type'] == 'authority': - sql = " DELETE FROM %s WHERE authority = %s" % \ - (self.tablename, record['hrn']) - self.db.do(sql) + params = {'authority': record['hrn']} + sql = template + "WHERE authority = %(authority)s" + self.db.do(sql, params) self.db.commit() def insert(self, record):