remove the site table and site record correctly when deleting sites
authorTony Mack <tmack@cs.princeton.edu>
Tue, 18 Aug 2009 01:10:04 +0000 (01:10 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 18 Aug 2009 01:10:04 +0000 (01:10 +0000)
sfa/plc/sfaImport.py
sfa/util/genitable.py

index fa33a04..8a567d7 100644 (file)
@@ -292,10 +292,16 @@ class sfaImport:
             hrn = parent_hrn + "." + node_name
         elif type in ['site'] and 'login_base' in object and object['login_base']:
             site_name = object['login_base']
-            hrn = parent_hrn + "." + site_name         
+            hrn = parent_hrn
+            parent_hrn = get_authority(hrn)
+            type = "authority"
+            # delete the site table
+            site_table = self.get_auth_table(hrn)
+            site_table.drop()
         else:
             return
-
+        
+        # delete the record
         table = self.get_auth_table(parent_hrn)
         record_list = table.resolve(type, hrn)
         if not record_list:
index 2025fe9..c09ac1a 100644 (file)
@@ -139,6 +139,15 @@ class GeniTable:
             result_rec_list.append(GeniRecord(dict=dict).as_dict())
         return result_rec_list
 
+    def drop(self):
+        try:
+            self.cnx.query('DROP TABLE IF EXISTS ' + self.tablename)
+        except ProgrammingError:
+            try:
+                self.cnx.query('DROP TABLE ' + self.tablename)
+            except ProgrammingError:
+                pass
+    
     @staticmethod
     def geni_records_purge(cninfo):