# coding: utf-8

import re

from django.core.management.base import BaseCommand, CommandError
from django.core import urlresolvers
from django.template.loader import render_to_string

from panacea.schemes import CacheScheme
from panacea.tools import get_logger
from panacea import config as conf

logger = get_logger()


class FakeRequest(object):
    def __init__(self, path='', query_string_dict=None,
                 cookies_dict=None, headers_dict=None):
        self.GET = query_string_dict or {}
        self.COOKIES = cookies_dict or {}
        self.META = headers_dict or {}
        self.path = path


class Command(BaseCommand):
    help = u"построение блока кофигурации nginx " \
           u"для кеширования описанных в конфиге api"

    def handle(self, *args, **options):
        schemes = self.get_schemes()
        if not schemes:
Example #2
0
# coding: utf-8
from django.contrib.contenttypes.models import ContentType

from cacheops.utils import dnf

from panacea import config as conf
from panacea import tools

logger = tools.get_logger()


class CacheConf(object):
    """
    класс, описывающий информацию о том,
    как надо кешировать модель, связанную с данным конфигом
    """
    def __init__(self, model_conf, urlconf):
        self.model_conf = model_conf
        self.urlconf = urlconf
        self.__model = None

    @property
    def model(self):
        if not self.__model:
            (app_label, model) = self.model_conf['model'].split('.')
            self.__model =  ContentType.objects.get(
                    app_label=app_label, model=model
                ).model_class()
        return self.__model

    @property