# Path: contentious/contrib/basictrans/models.py
# class TranslationContent(ContentItemBase):
#     """ Model for storing simple translations. """
# 
#     class Meta:
#         app_label = "contentious"
#         unique_together = (
#             ('language', 'key'),
#         )
# 
#     language = models.CharField(max_length=7)


from django.core.cache import cache
from contentious.contrib.basictrans.models import TranslationContent
from contentious.contrib.basictrans.utils import (
    content_dict_cache_key,
    get_cache_timeout,
)
            defaults=data
        )
        if not created:
            for key, value in data.items():
                setattr(obj, key, value)
            obj.save()
        self._clear_caches(template_context)

    def _get_lang(self, context):
        request = context['request']
        return request.language #expects the django i18n middleware to have activated it


    def _get_content_dict_for_lang(self, template_context):
        """ An efficient way for us to fetch content data without hitting the DB
            multiple times on the same request.  Tries to get the content by:
            1. getting it from a temporary cache on the request object, 2. getting
            it from memcache, 3. getting it from the database.
            Returns a dict of dicts.
        """
        language = self._get_lang(template_context)
        request = template_context['request']
        #The first time we fetch the content on a given request we store it on the request object
        try:
            return request._content_cache_dict
        except AttributeError:
            pass
        cache_key = content_dict_cache_key(language)
        content_dict = cache.get(cache_key)
        if content_dict is None:

# Path: contentious/contrib/basictrans/models.py
# class TranslationContent(ContentItemBase):
#     """ Model for storing simple translations. """
# 
#     class Meta:
#         app_label = "contentious"
#         unique_together = (
#             ('language', 'key'),
#         )
# 
#     language = models.CharField(max_length=7)


# Path: contentious/contrib/basictrans/api.py
from django.core.cache import cache
from contentious.contrib.basictrans.models import TranslationContent
from contentious.contrib.basictrans.utils import (
    content_dict_cache_key,
    get_cache_timeout,
)

            defaults=data
        )
        if not created:
            for key, value in data.items():
                setattr(obj, key, value)
            obj.save()
        self._clear_caches(template_context)

    def _get_lang(self, context):
        request = context['request']
        return request.language #expects the django i18n middleware to have activated it


    def _get_content_dict_for_lang(self, template_context):
        """ An efficient way for us to fetch content data without hitting the DB
            multiple times on the same request.  Tries to get the content by:
            1. getting it from a temporary cache on the request object, 2. getting
            it from memcache, 3. getting it from the database.
            Returns a dict of dicts.
        """
        language = self._get_lang(template_context)
        request = template_context['request']
        #The first time we fetch the content on a given request we store it on the request object
        try:
            return request._content_cache_dict
        except AttributeError:
            pass
        cache_key = content_dict_cache_key(language)
        content_dict = cache.get(cache_key)
        if content_dict is None:

            content_objects = TranslationContent.objects.filter(language=language)