def __getattr__(self, attr): if attr in self.__dict__: return getattr(self, attr) locale = i18n.current_lang(as_string=True) with self.i18n_views_lock: if locale not in self.memoized_views: self.memoized_views[locale] = MemoizedViews() # Look up the cache for this locale. obj = self.memoized_views[locale] # Forward the method call to the appropriate cache. return getattr(obj, attr)
def _i18n_dict(self): lang, locale, enc = i18n.current_lang() return self.__targets.setdefault((lang, locale), copy.copy(self.__original))