comparison src/tools/memory.py @ 418:199cf4ebcc74

core: removed former parameters files data location constants
author Goffi <goffi@goffi.org>
date Tue, 01 Nov 2011 23:06:18 +0100
parents f1bf8b6143b7
children acd908528ef7
comparison
equal deleted inserted replaced
417:f1bf8b6143b7 418:199cf4ebcc74
32 from sat.tools.xml_tools import paramsXml2xmlUI 32 from sat.tools.xml_tools import paramsXml2xmlUI
33 from sat.core.default_config import default_config 33 from sat.core.default_config import default_config
34 from sat.tools.sqlite import SqliteStorage 34 from sat.tools.sqlite import SqliteStorage
35 35
36 SAVEFILE_PARAM_XML="/param" #xml parameters template 36 SAVEFILE_PARAM_XML="/param" #xml parameters template
37 SAVEFILE_PARAM_DATA="/param" #individual & general parameters; _ind and _gen suffixes will be added
38 SAVEFILE_HISTORY="/history" 37 SAVEFILE_HISTORY="/history"
39 SAVEFILE_PRIVATE="/private" #file used to store misc values (mainly for plugins) 38 SAVEFILE_PRIVATE="/private" #file used to store misc values (mainly for plugins)
40 SAVEFILE_DATABASE="/sat.db" 39 SAVEFILE_DATABASE="/sat.db"
41 40
42 class ProfileNotInCacheError(Exception): 41 class ProfileNotInCacheError(Exception):
111 self.storage = storage 110 self.storage = storage
112 self.default_profile = None 111 self.default_profile = None
113 self.params = {} 112 self.params = {}
114 self.params_gen = {} 113 self.params_gen = {}
115 host.set_const('savefile_param_xml', SAVEFILE_PARAM_XML) 114 host.set_const('savefile_param_xml', SAVEFILE_PARAM_XML)
116 host.set_const('savefile_param_data', SAVEFILE_PARAM_DATA)
117 host.registerGeneralCB("registerNewAccount", host.registerNewAccountCB) 115 host.registerGeneralCB("registerNewAccount", host.registerNewAccountCB)
118 116
119 def createProfile(self, name): 117 def createProfile(self, name):
120 """Create a new profile 118 """Create a new profile
121 @param name: Name of the profile""" 119 @param name: Name of the profile"""
509 507
510 def loadFiles(self): 508 def loadFiles(self):
511 """Load parameters and all memory things from file/db""" 509 """Load parameters and all memory things from file/db"""
512 param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+ 510 param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+
513 self.host.get_const('savefile_param_xml')) 511 self.host.get_const('savefile_param_xml'))
514 param_file_data = os.path.expanduser(self.getConfig('','local_dir')+
515 self.host.get_const('savefile_param_data'))
516 history_file = os.path.expanduser(self.getConfig('','local_dir')+ 512 history_file = os.path.expanduser(self.getConfig('','local_dir')+
517 self.host.get_const('savefile_history')) 513 self.host.get_const('savefile_history'))
518 private_file = os.path.expanduser(self.getConfig('','local_dir')+ 514 private_file = os.path.expanduser(self.getConfig('','local_dir')+
519 self.host.get_const('savefile_private')) 515 self.host.get_const('savefile_private'))
520 516
568 def save(self): 564 def save(self):
569 """Save parameters and all memory things to file/db""" 565 """Save parameters and all memory things to file/db"""
570 #TODO: need to encrypt files (at least passwords !) and set permissions 566 #TODO: need to encrypt files (at least passwords !) and set permissions
571 param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+ 567 param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+
572 self.host.get_const('savefile_param_xml')) 568 self.host.get_const('savefile_param_xml'))
573 param_file_data = os.path.expanduser(self.getConfig('','local_dir')+
574 self.host.get_const('savefile_param_data'))
575 history_file = os.path.expanduser(self.getConfig('','local_dir')+ 569 history_file = os.path.expanduser(self.getConfig('','local_dir')+
576 self.host.get_const('savefile_history')) 570 self.host.get_const('savefile_history'))
577 private_file = os.path.expanduser(self.getConfig('','local_dir')+ 571 private_file = os.path.expanduser(self.getConfig('','local_dir')+
578 self.host.get_const('savefile_private')) 572 self.host.get_const('savefile_private'))
579 573