Lithuanian
[wolnelektury.git] / apps / picture / models.py
index 862c172..1e27ce6 100644 (file)
@@ -6,7 +6,7 @@ from django.conf import settings
 from django.core.files.storage import FileSystemStorage
 from django.utils.datastructures import SortedDict
 from django.template.loader import render_to_string
 from django.core.files.storage import FileSystemStorage
 from django.utils.datastructures import SortedDict
 from django.template.loader import render_to_string
-from django.core.cache import cache
+from django.core.cache import get_cache
 from catalogue.utils import split_tags
 from django.utils.safestring import mark_safe
 from slughifi import slughifi
 from catalogue.utils import split_tags
 from django.utils.safestring import mark_safe
 from slughifi import slughifi
@@ -44,9 +44,6 @@ class Picture(models.Model):
         verbose_name = _('picture')
         verbose_name_plural = _('pictures')
 
         verbose_name = _('picture')
         verbose_name_plural = _('pictures')
 
-    URLID_RE = r'[a-z0-9-]+'
-    FILEID_RE = r'[a-z0-9-]+'
-
     def save(self, force_insert=False, force_update=False, reset_short_html=True, **kwargs):
         from sortify import sortify
 
     def save(self, force_insert=False, force_update=False, reset_short_html=True, **kwargs):
         from sortify import sortify
 
@@ -64,10 +61,7 @@ class Picture(models.Model):
 
     @permalink
     def get_absolute_url(self):
 
     @permalink
     def get_absolute_url(self):
-        return ('picture.views.picture_detail', [self.urlid()])
-
-    def urlid(self):
-        return self.slug
+        return ('picture.views.picture_detail', [self.slug])
 
     @classmethod
     def from_xml_file(cls, xml_file, image_file=None, overwrite=False):
 
     @classmethod
     def from_xml_file(cls, xml_file, image_file=None, overwrite=False):
@@ -178,12 +172,12 @@ class Picture(models.Model):
             return
 
         cache_key = "Picture.short_html/%d" % (self.id)
             return
 
         cache_key = "Picture.short_html/%d" % (self.id)
-        cache.delete(cache_key)
+        get_cache('permanent').delete(cache_key)
 
     def short_html(self):
         if self.id:
             cache_key = "Picture.short_html/%d" % (self.id)
 
     def short_html(self):
         if self.id:
             cache_key = "Picture.short_html/%d" % (self.id)
-            short_html = cache.get(cache_key)
+            short_html = get_cache('permanent').get(cache_key)
         else:
             short_html = None
 
         else:
             short_html = None
 
@@ -197,5 +191,5 @@ class Picture(models.Model):
                 {'picture': self, 'tags': tags}))
 
             if self.id:
                 {'picture': self, 'tags': tags}))
 
             if self.id:
-                cache.set(cache_key, short_html, catalogue.models.CACHE_FOREVER)
+                get_cache('permanent').set(cache_key, short_html)
             return mark_safe(short_html)
             return mark_safe(short_html)