diff --git a/src/cmsplugin_blurp/renderers/data_source.py b/src/cmsplugin_blurp/renderers/data_source.py index 8b6d88c..5d1fb42 100644 --- a/src/cmsplugin_blurp/renderers/data_source.py +++ b/src/cmsplugin_blurp/renderers/data_source.py @@ -90,6 +90,14 @@ class Renderer(template.TemplateRenderer): if settings.TEMPLATE_DEBUG: yield 'blurp_debug__', '\n'.join(self.debug_content(context)) + def has_cached_content(self, context): + for source in self.config['sources']: + slug = '{0}.{1}'.format(self.slug, source['slug']) + data = Data(slug, self.config, source, context) + if not data.has_cached_content(): + return False + return True + def debug_content(self, context): try: yield u'config: {0}'.format(pprint.pformat(self.config)) @@ -319,6 +327,10 @@ class Data(object): UPDATE_THREADS = {} CONDITIONS = {} + def has_cached_content(self): + self.__content, until = cache.get(self.key, (self.__CACHE_SENTINEL, None)) + return self.__content is not self.__CACHE_SENTINEL + def get_content(self): if self.__content is not self.__CACHE_SENTINEL: return self.__content