# Path: djangocms_page_meta/utils.py
# def get_cache_key(page, language):
#     """
#     Create the cache key for the current page and language
#     """
#     from cms.cache import _get_cache_key
# 
#     try:
#         site_id = page.node.site_id
#     except AttributeError:  # CMS_3_4
#         site_id = page.site_id
#     return _get_cache_key("page_meta", page, language, site_id)
# 
# def get_metatags(request):
#     language = get_language_from_request(request, check_path=True)
#     meta = get_page_meta(request.current_page, language)
#     return mark_safe(
#         render_to_string(request=request, template_name="djangocms_page_meta/meta.html", context={"meta": meta})
#     )


from cms.extensions import PageExtension, TitleExtension
from cms.extensions.extension_pool import extension_pool
from cms.models import Page, Title
from django.conf import settings
from django.core.cache import cache
from django.db import models
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from filer.fields.file import FilerFileField
from meta import settings as meta_settings
from .utils import get_cache_key, get_metatags
    from aldryn_snake.template_api import registry

    class Meta:
        verbose_name = _("Page meta info (language-dependent)")
        verbose_name_plural = _("Page meta info (language-dependent)")

    def __str__(self):
        if self.page:
            return _("Attribute {0} for {1}").format(self.name, self.page)
        if self.title:
            return _("Attribute {0} for {1}").format(self.name, self.title)


# Cache cleanup when deleting pages / editing page extensions
@receiver(pre_delete, sender=Page)
def cleanup_page(sender, instance, **kwargs):
    for language in instance.get_languages():
        key = get_cache_key(instance, language)
        cache.delete(key)


@receiver(pre_delete, sender=Title)
def cleanup_title(sender, instance, **kwargs):
    key = get_cache_key(instance.page, instance.language)
    cache.delete(key)


@receiver(post_save, sender=PageMeta)
@receiver(pre_delete, sender=PageMeta)
def cleanup_pagemeta(sender, instance, **kwargs):
    for language in instance.extended_object.get_languages():

# Path: djangocms_page_meta/utils.py
# def get_cache_key(page, language):
#     """
#     Create the cache key for the current page and language
#     """
#     from cms.cache import _get_cache_key
# 
#     try:
#         site_id = page.node.site_id
#     except AttributeError:  # CMS_3_4
#         site_id = page.site_id
#     return _get_cache_key("page_meta", page, language, site_id)
# 
# def get_metatags(request):
#     language = get_language_from_request(request, check_path=True)
#     meta = get_page_meta(request.current_page, language)
#     return mark_safe(
#         render_to_string(request=request, template_name="djangocms_page_meta/meta.html", context={"meta": meta})
#     )


# Path: djangocms_page_meta/models.py
from cms.extensions import PageExtension, TitleExtension
from cms.extensions.extension_pool import extension_pool
from cms.models import Page, Title
from django.conf import settings
from django.core.cache import cache
from django.db import models
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from filer.fields.file import FilerFileField
from meta import settings as meta_settings
from .utils import get_cache_key, get_metatags
    from aldryn_snake.template_api import registry


    class Meta:
        verbose_name = _("Page meta info (language-dependent)")
        verbose_name_plural = _("Page meta info (language-dependent)")

    def __str__(self):
        if self.page:
            return _("Attribute {0} for {1}").format(self.name, self.page)
        if self.title:
            return _("Attribute {0} for {1}").format(self.name, self.title)


# Cache cleanup when deleting pages / editing page extensions
@receiver(pre_delete, sender=Page)
def cleanup_page(sender, instance, **kwargs):
    for language in instance.get_languages():
        key = get_cache_key(instance, language)
        cache.delete(key)


@receiver(pre_delete, sender=Title)
def cleanup_title(sender, instance, **kwargs):
    key = get_cache_key(instance.page, instance.language)
    cache.delete(key)


@receiver(post_save, sender=PageMeta)
@receiver(pre_delete, sender=PageMeta)
def cleanup_pagemeta(sender, instance, **kwargs):
    for language in instance.extended_object.get_languages():

        key = get_cache_key(instance.extended_object, language)