<commit_before># django imports
from django import template
from django.core.cache import cache

# portlets imports
import portlets.utils
from portlets.models import Slot

register = template.Library()

@register.inclusion_tag('portlets/portlet_slot.html', takes_context=True)
def portlet_slot(context, slot_name, instance=None):
    """Returns the portlets for given slot and instance. If the instance
    implements the ``get_parent_for_portlets`` method the portlets of the
    parent of the instance are also added.
    """
    request = context.get("request")

    # CACHE
    cache_key = "portlets-%s-%s-%s-%s-%s" % (instance.content_type, instance.id, slot_name, request.user.id, context.get("CURRENT_LANGUAGE"))
    rendered_portlets = cache.get(cache_key)

    if rendered_portlets:
        return { "portlets" : rendered_portlets }

    if instance is None:
        return { "portlets" : [] }

    try:
        slot = Slot.objects.get(name=slot_name)
    except Slot.DoesNotExist:
        return { "portlets" : [] }

    # Get portlets for given instance
    temp = portlets.utils.get_portlets(slot, instance)

    # Get inherited portlets
    try:
        instance.get_parent_for_portlets()
    except AttributeError:
        instance = None<commit_msg>cache keys are using CACHE_MIDDLEWARE_PREFIX now<commit_after># django imports
from django import template
from django.conf import settings
from django.core.cache import cache

# portlets imports
import portlets.utils
from portlets.models import Slot

register = template.Library()

@register.inclusion_tag('portlets/portlet_slot.html', takes_context=True)
def portlet_slot(context, slot_name, instance=None):
    """Returns the portlets for given slot and instance. If the instance
    implements the ``get_parent_for_portlets`` method the portlets of the
    parent of the instance are also added.
    """
    request = context.get("request")

    # CACHE
    cache_key = "%s-portlets-%s-%s-%s-%s-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
        instance.content_type, instance.id, slot_name, request.user.id, context.get("CURRENT_LANGUAGE"))
    rendered_portlets = cache.get(cache_key)

    if rendered_portlets:
        return { "portlets" : rendered_portlets }

    if instance is None:
        return { "portlets" : [] }

    try:
        slot = Slot.objects.get(name=slot_name)
    except Slot.DoesNotExist:
        return { "portlets" : [] }

    # Get portlets for given instance
    temp = portlets.utils.get_portlets(slot, instance)

    # Get inherited portlets
    try:
        instance.get_parent_for_portlets()
    except AttributeError:
        instance = None
{'fraction_non_alphanumeric': 0.09640831758034027, 'fraction_numerical': 0.0, 'mean_word_length': 3.6097560975609757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4213863', 'n_tokens_mistral': 798, 'n_tokens_neox': 787, 'n_words': 209}