def getCachedObject(obj,methods=[],depth=10.,expire=3.,catched=False):
""" @RISKY
This method will try to apply Cached decorator to all methods
of an object. USE IT AT YOUR OWN RISK!!
"""
klass = obj if isinstance(obj,type) else type(obj)
if not methods:
methods = [k for k,f in klass.__dict__.items() if isCallable(f)]
for k in methods:
try:
m = Cached(getattr(klass,k),depth,expire,catched=catched)
setattr(obj,k,m)
except:pass
return obj
评论列表
文章目录