Mercurial > libervia-backend
comparison tools/memory.py @ 66:8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
- Quick App: new single_profile parameter in __init__ (default: yes), used to tell if the application use only one profile at the time or not
- Quick App: new __check_profile method, tell if the profile is used by the current frontend
- Quick App: new methods plug_profile, unplug_profile and clear_profile, must be called by the frontend to tell which profiles to use
- DBus Bridge: new methods getProfileName, getProfilesList and createProfile
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 03 Feb 2010 23:35:57 +1100 |
parents | d35c5edab53f |
children | 9b842086d915 |
comparison
equal
deleted
inserted
replaced
65:d35c5edab53f | 66:8147b4f40809 |
---|---|
115 host.registerGeneralCB("registerNewAccount", host.registerNewAccountCB) | 115 host.registerGeneralCB("registerNewAccount", host.registerNewAccountCB) |
116 | 116 |
117 def getProfilesList(self): | 117 def getProfilesList(self): |
118 return self.params.keys() | 118 return self.params.keys() |
119 | 119 |
120 def createProfile(self, name, default=False): | 120 def createProfile(self, name): |
121 """Create a new profile | 121 """Create a new profile |
122 @param name: Name of the profile | 122 @param name: Name of the profile |
123 @param default: True if default value""" | 123 @param default: True if default value""" |
124 if self.params.has_key(name): | 124 if self.params.has_key(name): |
125 info ('The profile name already exists') | 125 info ('The profile name already exists') |
133 @ALL@ for all profiles | 133 @ALL@ for all profiles |
134 @DEFAULT@ for default profile | 134 @DEFAULT@ for default profile |
135 @return: requested profile name or None if it doesn't exist""" | 135 @return: requested profile name or None if it doesn't exist""" |
136 if profile_key=='@DEFAULT@': | 136 if profile_key=='@DEFAULT@': |
137 if not self.params: | 137 if not self.params: |
138 return None | 138 return "" |
139 info('No default profile, returning first one') #TODO: manage real default profile | 139 info('No default profile, returning first one') #TODO: manage real default profile |
140 return self.params.keys()[0] #FIXME: gof: temporary, must use real default value, and fallback to first one if it doesn't exists | 140 return self.params.keys()[0] #FIXME: gof: temporary, must use real default value, and fallback to first one if it doesn't exists |
141 if not self.params.has_key(profile_key): | 141 if not self.params.has_key(profile_key): |
142 error ('Trying to access an unknown profile') | 142 error ('Trying to access an unknown profile') |
143 return None | 143 return "" |
144 return profile_key | 144 return profile_key |
145 | 145 |
146 def __get_unique_node(self, parent, tag, name): | 146 def __get_unique_node(self, parent, tag, name): |
147 """return node with given tag | 147 """return node with given tag |
148 @param parent: parent of nodes to check (e.g. documentElement) | 148 @param parent: parent of nodes to check (e.g. documentElement) |
352 type = node[1].getAttribute("type") | 352 type = node[1].getAttribute("type") |
353 if type=="button": | 353 if type=="button": |
354 print "clique",node.toxml() | 354 print "clique",node.toxml() |
355 else: | 355 else: |
356 self.params[profile][(category, name)] = value | 356 self.params[profile][(category, name)] = value |
357 self.host.bridge.paramUpdate(name, value, category) #TODO: add profile in signal | 357 self.host.bridge.paramUpdate(name, value, category, profile) #TODO: add profile in signal |
358 | 358 |
359 class Memory: | 359 class Memory: |
360 """This class manage all persistent informations""" | 360 """This class manage all persistent informations""" |
361 | 361 |
362 def __init__(self, host): | 362 def __init__(self, host): |
603 return self.params.getParamA(name, category, attr, profile_key) | 603 return self.params.getParamA(name, category, attr, profile_key) |
604 | 604 |
605 def getParams(self): | 605 def getParams(self): |
606 return self.params.getParams() | 606 return self.params.getParams() |
607 | 607 |
608 def getParamsForCategory(self, category): | 608 def getParamsForCategory(self, category, profile_key='@DEFAULT@'): |
609 return self.params.getParamsForCategory(category) | 609 return self.params.getParamsForCategory(category, profile_key) |
610 | 610 |
611 def getParamsCategories(self): | 611 def getParamsCategories(self): |
612 return self.params.getParamsCategories() | 612 return self.params.getParamsCategories() |
613 | 613 |
614 def setParam(self, name, value, category, profile_key='@DEFAULT@'): | 614 def setParam(self, name, value, category, profile_key='@DEFAULT@'): |