當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.make_template_fragment_key方法代碼示例

本文整理匯總了Python中django.core.cache.utils.make_template_fragment_key方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.make_template_fragment_key方法的具體用法?Python utils.make_template_fragment_key怎麽用?Python utils.make_template_fragment_key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.core.cache.utils的用法示例。


在下文中一共展示了utils.make_template_fragment_key方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: user_config

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def user_config(self, data):
        newd = dict(
            list_display=data.getlist('list_display'),
            list_only_date=data.get('list_only_date', 1)
        )
        content = json.dumps(newd)
        config = Configure.objects.filter(
            content_type=get_content_type_for_model(self.model),
            onidc_id=self.onidc_id, creator=self.request.user,
            mark='list').order_by('-pk')
        if config.exists():
            config = config.update(content=content)
        else:
            config = Configure.objects.create(
                content_type=get_content_type_for_model(self.model),
                onidc_id=self.onidc_id, creator=self.request.user,
                mark='list', content=content)
        key = utils.make_template_fragment_key("{}.{}.{}".format(
            self.request.user.id, self.model_name, 'list'))
        cache.delete(key)
        return config 
開發者ID:Wenvki,項目名稱:django-idcops,代碼行數:23,代碼來源:list.py

示例2: problem_update

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def problem_update(sender, instance, **kwargs):
    if hasattr(instance, '_updating_stats_only'):
        return

    cache.delete_many([
        make_template_fragment_key('submission_problem', (instance.id,)),
        make_template_fragment_key('problem_feed', (instance.id,)),
        'problem_tls:%s' % instance.id, 'problem_mls:%s' % instance.id,
    ])
    cache.delete_many([make_template_fragment_key('problem_html', (instance.id, engine, lang))
                       for lang, _ in settings.LANGUAGES for engine in EFFECTIVE_MATH_ENGINES])
    cache.delete_many([make_template_fragment_key('problem_authors', (instance.id, lang))
                       for lang, _ in settings.LANGUAGES])
    cache.delete_many(['generated-meta-problem:%s:%d' % (lang, instance.id) for lang, _ in settings.LANGUAGES])

    for lang, _ in settings.LANGUAGES:
        unlink_if_exists(get_pdf_path('%s.%s.pdf' % (instance.code, lang))) 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:19,代碼來源:signals.py

示例3: handle

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def handle(self, request, org, profile):
        if profile.organizations.filter(id=org.id).exists():
            return generic_message(request, _('Joining organization'), _('You are already in the organization.'))

        if not org.is_open:
            return generic_message(request, _('Joining organization'), _('This organization is not open.'))

        max_orgs = settings.DMOJ_USER_MAX_ORGANIZATION_COUNT
        if profile.organizations.filter(is_open=True).count() >= max_orgs:
            return generic_message(
                request, _('Joining organization'),
                _('You may not be part of more than {count} public organizations.').format(count=max_orgs),
            )

        profile.organizations.add(org)
        profile.save()
        cache.delete(make_template_fragment_key('org_member_count', (org.id,))) 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:19,代碼來源:organization.py

示例4: save

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def save(self, *args, **kwargs):
        super(Partner, self).save(*args, **kwargs)
        """Invalidate this partner's pandoc-rendered html from cache"""
        for code in RESOURCE_LANGUAGE_CODES:
            short_description_cache_key = make_template_fragment_key(
                "partner_short_description", [code, self.pk]
            )
            description_cache_key = make_template_fragment_key(
                "partner_description", [code, self.pk]
            )
            send_instructions_cache_key = make_template_fragment_key(
                "partner_send_instructions", [code, self.pk]
            )
            cache.delete(short_description_cache_key)
            cache.delete(description_cache_key)
            cache.delete(send_instructions_cache_key) 
開發者ID:WikipediaLibrary,項目名稱:TWLight,代碼行數:18,代碼來源:models.py

示例5: _config

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def _config(self):
        key = utils.make_template_fragment_key("{}.{}.{}".format(
            self.request.user.id, self.model_name, 'list'))
        data = cache.get_or_set(key, 
            get_user_config(self.request.user, 'list', self.model), 180)
        return data 
開發者ID:Wenvki,項目名稱:django-idcops,代碼行數:8,代碼來源:list.py

示例6: make_cache_key

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def make_cache_key(key):
    return cache_key.make_template_fragment_key(key) 
開發者ID:Wenvki,項目名稱:django-idcops,代碼行數:4,代碼來源:utils.py

示例7: render

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def render(self, context):
        try:
            expire_time = self.expire_time_var.resolve(context)
        except VariableDoesNotExist:
            raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.expire_time_var.var)
        try:
            expire_time = int(expire_time)
        except (ValueError, TypeError):
            raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time)
        if self.cache_name:
            try:
                cache_name = self.cache_name.resolve(context)
            except VariableDoesNotExist:
                raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.cache_name.var)
            try:
                fragment_cache = caches[cache_name]
            except InvalidCacheBackendError:
                raise TemplateSyntaxError('Invalid cache name specified for cache tag: %r' % cache_name)
        else:
            try:
                fragment_cache = caches['template_fragments']
            except InvalidCacheBackendError:
                fragment_cache = caches['default']

        vary_on = [var.resolve(context) for var in self.vary_on]
        cache_key = make_template_fragment_key(self.fragment_name, vary_on)
        value = fragment_cache.get(cache_key)
        if value is None:
            value = self.nodelist.render(context)
            fragment_cache.set(cache_key, value, expire_time)
        return value 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:33,代碼來源:cache.py

示例8: post

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def post(self, request, *args, **kwargs):

        # Delete cached data for the legends
        legend_top_key = make_template_fragment_key('legend_partial_top')
        cache.delete(legend_top_key)
        legend_bottom_key = make_template_fragment_key('legend_partial_bottom')
        cache.delete(legend_bottom_key)

        # Delete cached data for the host format string
        cache.delete('host_output_format_string')

        return super(UpdateDynamicSettingsView, self).post(request, *args, **kwargs) 
開發者ID:lmco,項目名稱:dart,代碼行數:14,代碼來源:views.py

示例9: cache

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def cache(self, *args, **kwargs):
        cache_alias = kwargs.get('cache_alias', DEFAULT_CACHE_ALIAS)
        cache_key = kwargs.get('cache_key', kwargs['default_cache_key'])
        if cache_key is None:
            raise ValueError(
                'You must set `cache_key` when the template is not a file.')
        cache_key = make_template_fragment_key(cache_key, args)

        out = caches[cache_alias].get(cache_key)
        if out is None:
            out = kwargs['caller']()
            caches[cache_alias].set(cache_key, out, kwargs.get('timeout'))
        return out 
開發者ID:noripyt,項目名稱:django-cachalot,代碼行數:15,代碼來源:jinja2ext.py

示例10: render

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def render(self, context):
        try:
            expire_time = self.expire_time_var.resolve(context)
        except VariableDoesNotExist:
            raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.expire_time_var.var)
        if expire_time is not None:
            try:
                expire_time = int(expire_time)
            except (ValueError, TypeError):
                raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time)
        if self.cache_name:
            try:
                cache_name = self.cache_name.resolve(context)
            except VariableDoesNotExist:
                raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.cache_name.var)
            try:
                fragment_cache = caches[cache_name]
            except InvalidCacheBackendError:
                raise TemplateSyntaxError('Invalid cache name specified for cache tag: %r' % cache_name)
        else:
            try:
                fragment_cache = caches['template_fragments']
            except InvalidCacheBackendError:
                fragment_cache = caches['default']

        vary_on = [var.resolve(context) for var in self.vary_on]
        cache_key = make_template_fragment_key(self.fragment_name, vary_on)
        value = fragment_cache.get(cache_key)
        if value is None:
            value = self.nodelist.render(context)
            fragment_cache.set(cache_key, value, expire_time)
        return value 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:34,代碼來源:cache.py

示例11: get

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def get(self, request, *args, **kwargs):
        """
        Method that handles the GET requests for this view. Sets all other ``DataProduct``s to unfeatured in the
        database, and sets the specified ``DataProduct`` to featured. Caches the featured image. Deletes previously
        featured images from the cache.
        """
        product_id = kwargs.get('pk', None)
        product = DataProduct.objects.get(pk=product_id)
        try:
            current_featured = DataProduct.objects.filter(
                featured=True,
                data_product_type=product.data_product_type,
                target=product.target
            )
            for featured_image in current_featured:
                featured_image.featured = False
                featured_image.save()
                featured_image_cache_key = make_template_fragment_key(
                    'featured_image',
                    str(featured_image.target.id)
                )
                cache.delete(featured_image_cache_key)
        except DataProduct.DoesNotExist:
            pass
        product.featured = True
        product.save()
        return redirect(reverse(
            'tom_targets:detail',
            kwargs={'pk': request.GET.get('target_id')})
        ) 
開發者ID:TOMToolkit,項目名稱:tom_base,代碼行數:32,代碼來源:views.py

示例12: invalidate_cache

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def invalidate_cache(self):
        """
        Invalidate the HTML cache for all the publications of this researcher.
        """
        for a in self.authors+[None]:
            rpk = None
            if a:
                if a.researcher_id is None:
                    continue
                else:
                    rpk = a.researcher_id
            for lang in settings.POSSIBLE_LANGUAGE_CODES:
                key = make_template_fragment_key(
                    'publiListItem', [self.pk, lang, rpk])
                cache.delete(key) 
開發者ID:dissemin,項目名稱:dissemin,代碼行數:17,代碼來源:models.py

示例13: profile_update

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def profile_update(sender, instance, **kwargs):
    if hasattr(instance, '_updating_stats_only'):
        return

    cache.delete_many([make_template_fragment_key('user_about', (instance.id, engine))
                       for engine in EFFECTIVE_MATH_ENGINES] +
                      [make_template_fragment_key('org_member_count', (org_id,))
                       for org_id in instance.organizations.values_list('id', flat=True)]) 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:10,代碼來源:signals.py

示例14: contest_update

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def contest_update(sender, instance, **kwargs):
    if hasattr(instance, '_updating_stats_only'):
        return

    cache.delete_many(['generated-meta-contest:%d' % instance.id] +
                      [make_template_fragment_key('contest_html', (instance.id, engine))
                       for engine in EFFECTIVE_MATH_ENGINES]) 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:9,代碼來源:signals.py

示例15: license_update

# 需要導入模塊: from django.core.cache import utils [as 別名]
# 或者: from django.core.cache.utils import make_template_fragment_key [as 別名]
def license_update(sender, instance, **kwargs):
    cache.delete(make_template_fragment_key('license_html', (instance.id,))) 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:4,代碼來源:signals.py


注:本文中的django.core.cache.utils.make_template_fragment_key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。