0001 class Delegator: 0002 0003 # The cache is only used to be able to change delegates! 0004 0005 def __init__(self, delegate=None): 0006 self.delegate = delegate 0007 self.__cache = {} 0008 0009 def __getattr__(self, name): 0010 attr = getattr(self.delegate, name) # May raise AttributeError 0011 setattr(self, name, attr) 0012 self.__cache[name] = attr 0013 return attr 0014 0015 def resetcache(self): 0016 for key in self.__cache.keys(): 0017 try: 0018 delattr(self, key) 0019 except AttributeError: 0020 pass 0021 self.__cache.clear() 0022 0023 def cachereport(self): 0024 keys = self.__cache.keys() 0025 keys.sort() 0026 print keys 0027 0028 def setdelegate(self, delegate): 0029 self.resetcache() 0030 self.delegate = delegate 0031 0032 def getdelegate(self): 0033 return self.delegate 0034
Generated by PyXR 0.9.4