def clear_cache(sender, instance, **kwargs): # pylint: disable=unused-argument """ Clear the cached template when the model is saved """ cache_key = "template_cache." + fasthash( instance.microsite.site.domain + '.' + instance.template_uri) cache.delete(cache_key) # pylint: disable=maybe-no-member
def get_template(self, uri): """ Override of the base class for us to look into the database tables for a template definition, if we can't find one we'll return None which means "use default means" (aka filesystem) """ cache_key = "template_cache." + fasthash( microsite_get_value('site_domain') + '.' + uri) template_text = cache.get(cache_key) # pylint: disable=maybe-no-member if not template_text: # cache is empty so pull template from DB and fill cache. template_obj = MicrositeTemplate.get_template_for_microsite( microsite_get_value('site_domain'), uri) if not template_obj: # We need to set something in the cache to improve performance # of the templates stored in the filesystem as well cache.set( # pylint: disable=maybe-no-member cache_key, '##none', settings.MICROSITE_DATABASE_TEMPLATE_CACHE_TTL) return None template_text = template_obj.template cache.set( # pylint: disable=maybe-no-member cache_key, template_text, settings.MICROSITE_DATABASE_TEMPLATE_CACHE_TTL) if template_text == '##none': return None return Template(text=template_text)
def get_template(self, uri): """ Override of the base class for us to look into the database tables for a template definition, if we can't find one we'll return None which means "use default means" (aka filesystem) """ cache_key = "template_cache." + fasthash(microsite_get_value('site_domain') + '.' + uri) template_text = cache.get(cache_key) # pylint: disable=maybe-no-member if not template_text: # cache is empty so pull template from DB and fill cache. template_obj = MicrositeTemplate.get_template_for_microsite( microsite_get_value('site_domain'), uri ) if not template_obj: # We need to set something in the cache to improve performance # of the templates stored in the filesystem as well cache.set( # pylint: disable=maybe-no-member cache_key, '##none', settings.MICROSITE_DATABASE_TEMPLATE_CACHE_TTL ) return None template_text = template_obj.template cache.set( # pylint: disable=maybe-no-member cache_key, template_text, settings.MICROSITE_DATABASE_TEMPLATE_CACHE_TTL ) if template_text == '##none': return None return Template( text=template_text )
def clear_cache(sender, instance, **kwargs): # pylint: disable=unused-argument """ Clear the cached template when the model is saved """ cache_key = "template_cache." + fasthash(instance.microsite.site.domain + '.' + instance.template_uri) cache.delete(cache_key) # pylint: disable=maybe-no-member