From 98fd2a8a68400f9b7056d2225028fc5edea4cb68 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Tue, 18 Aug 2009 01:10:04 +0000 Subject: [PATCH] remove the site table and site record correctly when deleting sites --- sfa/plc/sfaImport.py | 10 ++++++++-- sfa/util/genitable.py | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sfa/plc/sfaImport.py b/sfa/plc/sfaImport.py index fa33a04a..8a567d77 100644 --- a/sfa/plc/sfaImport.py +++ b/sfa/plc/sfaImport.py @@ -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: diff --git a/sfa/util/genitable.py b/sfa/util/genitable.py index 2025fe9a..c09ac1ac 100644 --- a/sfa/util/genitable.py +++ b/sfa/util/genitable.py @@ -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): -- 2.43.0