Changeset 1510 for trunk/pylucid/PyLucid/models.py
- Timestamp:
- 03/27/08 16:59:44 (8 months ago)
- Files:
-
- 1 modified
-
trunk/pylucid/PyLucid/models.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/PyLucid/models.py
r1507 r1510 18 18 import os, posixpath, pickle 19 19 20 from django.conf import settings 20 21 from django.db import models 21 from django.co ntrib.auth.models import User, Group22 from django.contrib.auth.models import U NUSABLE_PASSWORD22 from django.core.cache import cache 23 from django.contrib.auth.models import User, Group, UNUSABLE_PASSWORD 23 24 from django.utils.translation import ugettext as _ 24 from django.conf import settings25 25 26 26 from PyLucid.tools.shortcuts import getUniqueShortcut 27 27 from PyLucid.tools import crypt 28 28 from PyLucid.system.utils import get_uri_base 29 #from PyLucid.db.cache import delete_page_cache 29 30 30 31 … … 38 39 ) 39 40 41 def delete_page_cache(): 42 """ 43 Delete all pages in the cache. 44 Needed, if: 45 - A template has been edited 46 - The menu changes (edit the page name, position, parent link) 47 TODO: move this function from models.py into a other nice place... 48 """ 49 for items in Page.objects.values('shortcut').iterator(): 50 shortcut = items["shortcut"] 51 cache_key = settings.PAGE_CACHE_PREFIX + shortcut 52 cache.delete(cache_key) 53 40 54 41 55 class Page(models.Model): 42 56 """ 43 57 A CMS Page Object 58 59 TODO: We should refactor the "pre_save" behavior, use signals: 60 http://code.djangoproject.com/wiki/Signals 44 61 """ 45 62 # Explicite id field, so we can insert a help_text ;) … … 239 256 self._check_parent(self.id) 240 257 258 # Delete all pages in the cache. 259 # FIXME: This is only needed, if the menu changed: e.g.: if the page 260 # position, shortcut, parent cahnges... 261 delete_page_cache() 262 241 263 # Rebuild shortcut / make shortcut unique: 242 264 self._prepare_shortcut() 265 266 # Delete old page cache, if exist 267 cache_key = settings.PAGE_CACHE_PREFIX + self.shortcut 268 cache.delete(cache_key) 243 269 244 270 super(Page, self).save() # Call the "real" save() method … … 711 737 pass 712 738 739 #Delete the page cache if a stylesheet was edited. 740 delete_page_cache() 741 713 742 super(Style, self).save() # Call the "real" save() method 714 743 … … 729 758 description = models.TextField() 730 759 content = models.TextField() 760 761 def save(self): 762 """ 763 Delete the page cache if a template was edited. 764 """ 765 delete_page_cache() 766 767 super(Template, self).save() # Call the "real" save() method 731 768 732 769 class Admin:
