Add caching to gconf
This commit is contained in:
parent
53f83bf39a
commit
296119cf79
|
@ -152,6 +152,7 @@ class TerminatorConfValuestoreRC (TerminatorConfValuestore):
|
||||||
class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
|
class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
|
||||||
profile = ""
|
profile = ""
|
||||||
client = None
|
client = None
|
||||||
|
cache = {}
|
||||||
|
|
||||||
def __init__ (self, profile = None):
|
def __init__ (self, profile = None):
|
||||||
self.type = "GConf"
|
self.type = "GConf"
|
||||||
|
@ -196,11 +197,17 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
def on_gconf_notify (self, client, cnxn_id, entry, what):
|
def on_gconf_notify (self, client, cnxn_id, entry, what):
|
||||||
|
dbg (" VSGConf: invalidating cache")
|
||||||
|
self.cache = {}
|
||||||
dbg (" VSGConf: gconf changed, callback is: %s"%self.reconfigure_callback)
|
dbg (" VSGConf: gconf changed, callback is: %s"%self.reconfigure_callback)
|
||||||
if self.reconfigure_callback:
|
if self.reconfigure_callback:
|
||||||
self.reconfigure_callback ()
|
self.reconfigure_callback ()
|
||||||
|
|
||||||
def __getattr__ (self, key = ""):
|
def __getattr__ (self, key = ""):
|
||||||
|
if self.cache.has_key (key):
|
||||||
|
dbg (" VSGConf: returning cached value: %s"%self.cache[key])
|
||||||
|
return (self.cache[key])
|
||||||
|
|
||||||
ret = None
|
ret = None
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
|
@ -242,6 +249,7 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
|
||||||
typefunc = getattr (value, funcname)
|
typefunc = getattr (value, funcname)
|
||||||
ret = typefunc ()
|
ret = typefunc ()
|
||||||
|
|
||||||
|
self.cache[key] = ret
|
||||||
return (ret)
|
return (ret)
|
||||||
else:
|
else:
|
||||||
raise (AttributeError)
|
raise (AttributeError)
|
||||||
|
|
Loading…
Reference in New Issue