routines to store site list in config

This commit is contained in:
sqlcoder 2010-08-31 22:34:48 +01:00
parent bf8b826bbc
commit 9704cd7fe5
2 changed files with 18 additions and 1 deletions

View File

@ -697,10 +697,11 @@ class Config:
self.aux_windows = {}
self.hhcs = {}
self.popup_windows = {}
self.db_selected = None # database the user would like to use
self.db_selected = None # database the user would like to use
self.general = General()
self.emails = {}
self.gui_cash_stats = GUICashStats()
self.site_ids = {} # site ID list from the database
added,n = 1,0 # use n to prevent infinite loop if add_missing_elements() fails somehow
while added > 0 and n < 2:
@ -1390,6 +1391,12 @@ class Config:
if font_size is not None: site_node.setAttribute("font_size", font_size)
return
def set_site_ids(self, sites):
self.site_ids = dict(sites)
def get_site_id(self, site):
return( self.site_ids[site] )
def get_aux_windows(self):
"""Gets the list of mucked window formats in the configuration."""
return self.aux_windows.keys()

View File

@ -302,6 +302,7 @@ class Database:
self.saveActions = False if self.import_options['saveActions'] == False else True
if self.is_connected():
self.get_sites()
self.connection.rollback() # make sure any locks taken so far are released
#end def __init__
@ -466,6 +467,15 @@ class Database:
self.cursor.execute(self.sql.query['set tx level'])
self.check_version(database=database, create=create)
def get_sites(self):
self.cursor.execute("SELECT name,id FROM Sites")
sites = self.cursor.fetchall()
self.config.set_site_ids(sites)
def add_site(self, site, site_code):
self.cursor.execute("INSERT INTO Sites "
"SELECT max(id)+1, '%s', '%s' "
"FROM Sites " % (site, site_code) )
def check_version(self, database, create):
self.wrongDbVersion = False