- def __getattr__(self, name):
- method = getattr(self.api, name)
- if method is None:
- raise AssertionError("method does not exist")
-
- def run_or_returncached(*params):
- cachename = self._param_to_str(name, *params)
- #print "cachename is %s" % cachename
- if hasattr(config, 'refresh'):
- refresh = config.refresh
- else:
- refresh = False
-
- if 'Get' in name:
- if not database.cachedRecently(cachename):
- load_old_cache = False
- try:
- values = method(self.auth, *params)
- except:
- print "Call %s FAILED: Using old cached data" % cachename
- load_old_cache = True
-
- if load_old_cache:
- values = database.dbLoad(cachename)
- else:
- database.dbDump(cachename, values)
-
- return values
- else:
- values = database.dbLoad(cachename)
- return values
- else:
- return method(self.auth, *params)
-
- return run_or_returncached