コード例 #1
0
ファイル: Page.py プロジェクト: jedie/PyLucid-old-v0.8-trunk
    def save(self, *args, **kwargs):
        """
        Save a new page or update changed page data.
        before save: check some data consistency to prevents inconsistent data.
        """
        from PyLucid.system.utils import delete_page_cache
        if self.id != None:
            # a existing page should be updated (It's not a new page ;)

            # Check some settings for the default index page:
            self._check_default_page_settings()

            # check if a new parent is no parent-child-loop:
            self._check_parent(self.id)

        # Delete all pages in the cache.
        # FIXME: This is only needed, if the menu changed: e.g.: if the page
        # position, shortcut, parent cahnges...
        delete_page_cache()

        # name and shortcut can be None, for make shortcut unique
        if self.name == None:
            self.name = ""
        if self.shortcut == None:
            self.shortcut = ""

        # Rebuild shortcut / make shortcut unique:
        self._prepare_shortcut()

        # Delete old page cache, if exist
        cache_key = settings.PAGE_CACHE_PREFIX + self.shortcut
        cache.delete(cache_key)

        super(Page, self).save(*args, **kwargs) # Call the "real" save() method
コード例 #2
0
    def save(self, *args, **kwargs):
        """
        Delete the page cache if a template was edited.
        """
        if self.pk == None:
            # Create a new template (e.g. used the save_as function)
            # http://www.djangoproject.com/documentation/admin/#save-as
            # The name must be unique.
            if self.description == None:
                self.description = ""
            self.description += " (copy from %s)" % self.name
            existing_names = Template.objects.values_list("name", flat=True)
            # add a number if the name exist
            self.name = makeUnique(self.name, existing_names)

        delete_page_cache()

        super(Template, self).save(*args, **kwargs)  # Call the "real" save() method
コード例 #3
0
ファイル: Page.py プロジェクト: jedie/PyLucid-old-v0.8-trunk
 def delete(self):
     # Delete all pages in the cache.
     from PyLucid.system.utils import delete_page_cache
     delete_page_cache()
     super(Page, self).delete()