def new_f(request, *args, **kwargs): if not DEBUG and (not self.condition or self.condition(request, *args, **kwargs)): resName = Cached.resName(f, request.__class__,*args, **kwargs) res = cache.get(resName) if not res: res = f(request, *args, **kwargs) cache.set(resName, res, self.time, namespace=self.namespace) return res else: return f(request, *args, **kwargs)
def getViewsDict(directory, base=''): result = {} memResult = cache.get('paths_ViewsDict_'+directory) if memResult is None: if os.path.exists(directory) and os.path.isdir(directory): for f in os.listdir(directory): rf = os.path.join(directory, f) if os.path.isfile(rf): result[f[:f.rindex('.')]] = os.path.abspath(rf)#[base and len(base) or 0:] cache.set(key='paths_ViewsDict', item=result) memResult = result return memResult