Merge branch 'master' of ssh://git.planet-lab.org/git/sfa
[sfa.git] / sfa / util / table.py
index f6090a0..44d0b86 100644 (file)
@@ -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):