Esempio n. 1
0
def cleanup_cache(request):
    """ remove everything from the cache """
    if request.method != "POST":
        form = CleanCacheForm()
    else:
        form = CleanCacheForm(request.POST)
        if form.is_valid():
            update_type = form.cleaned_data["update_type"]
            start_time = time.time()
            if update_type == CleanCacheForm.SMOOTH:
                try:
                    cache.smooth_update()
                except AttributeError, err:
                    messages.error(
                        request,
                        _("Error: %s (django-tools SmoothCacheBackend not used?"
                          ) % err)
                    return HttpResponseRedirect(request.path)
            elif update_type == CleanCacheForm.CLEAR:
                cache.clear()
            else:
                raise  # Should never happen
            duration_time = time.time() - start_time
            messages.success(
                request,
                _("Everything from the Django's cache framework was deleted in %(duration).2fsec"
                  ) % {"duration": duration_time})
            return HttpResponseRedirect(request.path)
Esempio n. 2
0
    def save(self, *args, **kwargs):
        """
        Save and update the cache
        """
        super(LexiconEntry, self).save(*args, **kwargs)

        try:
            cache.smooth_update()  # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()
Esempio n. 3
0
    def save(self, *args, **kwargs):
        if self.pagemeta.pagetree.page_type != self.pagemeta.pagetree.PAGE_TYPE:
            # TODO: move to django model validation
            raise AssertionError("PageContent can only exist on a page type tree entry!")

        try:
            cache.smooth_update() # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()

        return super(PageContent, self).save(*args, **kwargs)
Esempio n. 4
0
    def save(self, *args, **kwargs):
        """
        Save and update the cache
        """
        super(LexiconEntry, self).save(*args, **kwargs)

        try:
            cache.smooth_update(
            )  # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()
Esempio n. 5
0
    def save(self, *args, **kwargs):
        if self.pagemeta.pagetree.page_type != self.pagemeta.pagetree.PAGE_TYPE:
            # TODO: move to django model validation
            raise AssertionError(
                "PageContent can only exist on a page type tree entry!")

        try:
            cache.smooth_update(
            )  # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()

        return super(PageContent, self).save(*args, **kwargs)
Esempio n. 6
0
    def save(self, *args, **kwargs):
        """
        Clean the complete cache.
        
        FIXME: clean only the blog summary and detail page:
            http://www.python-forum.de/topic-22739.html (de)
        """
        super(BlogEntry, self).save(*args, **kwargs)

        try:
            cache.smooth_update() # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()
Esempio n. 7
0
    def save(self, *args, **kwargs):
        """
        Clean the complete cache.
        
        FIXME: clean only the blog summary and detail page:
            http://www.python-forum.de/topic-22739.html (de)
        """
        super(BlogEntry, self).save(*args, **kwargs)

        try:
            cache.smooth_update(
            )  # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()
Esempio n. 8
0
    def save(self, *args, **kwargs):
        """ reset PageMeta and PageTree url cache """
        # Clean the local url cache dict
        self._url_cache.clear()
        self._permalink_cache.clear()
        self.pagetree._url_cache.clear()

        # FIXME: We must only update the cache for the current SITE not for all sites.
        try:
            cache.smooth_update() # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()

        return super(PageMeta, self).save(*args, **kwargs)
Esempio n. 9
0
    def save(self, *args, **kwargs):
        if not self.pagetree.page_type == self.pagetree.PLUGIN_TYPE:
            # FIXME: Better error with django model validation?
            raise AssertionError("Plugin can only exist on a plugin type tree entry!")

        _URL_RESOLVER_CACHE.clear()

        # FIXME: We must only update the cache for the current SITE not for all sites.
        try:
            cache.smooth_update() # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()

        return super(PluginPage, self).save(*args, **kwargs)
Esempio n. 10
0
    def save(self, *args, **kwargs):
        if not self.pagetree.page_type == self.pagetree.PLUGIN_TYPE:
            # FIXME: Better error with django model validation?
            raise AssertionError(
                "Plugin can only exist on a plugin type tree entry!")

        _URL_RESOLVER_CACHE.clear()

        # FIXME: We must only update the cache for the current SITE not for all sites.
        try:
            cache.smooth_update(
            )  # Save "last change" timestamp in django-tools SmoothCacheBackend
        except AttributeError:
            # No SmoothCacheBackend used -> clean the complete cache
            cache.clear()

        return super(PluginPage, self).save(*args, **kwargs)
Esempio n. 11
0
def cleanup_cache(request):
    """ remove everything from the cache """
    if request.method != "POST":
        form = CleanCacheForm()
    else:
        form = CleanCacheForm(request.POST)
        if form.is_valid():
            update_type = form.cleaned_data["update_type"]
            start_time = time.time()
            if update_type == CleanCacheForm.SMOOTH:
                try:
                    cache.smooth_update()
                except AttributeError, err:
                    messages.error(request, _("Error: %s (django-tools SmoothCacheBackend not used?") % err)
                    return HttpResponseRedirect(request.path)
            elif update_type == CleanCacheForm.CLEAR:
                cache.clear()
            else:
                raise # Should never happen
            duration_time = time.time() - start_time
            messages.success(request, _("Everything from the Django's cache framework was deleted in %(duration).2fsec") % {
                "duration":duration_time
            })
            return HttpResponseRedirect(request.path)
Esempio n. 12
0
        try:
            mail_admins(subject, emailtext, fail_silently=False)
        except Exception, err:
            LogEntry.objects.log_action(
                app_label=APP_LABEL, action="mail error", message="Admin mail, can't send: %s" % err,
            )

    # delete the item from cache
    absolute_url = content_object.get_absolute_url()
    language_code = content_object.language.code
    delete_cache_item(absolute_url, language_code, site.id)

    # FIXME: We must only update the cache for the current SITE not for all sites.
    try:
        cache.smooth_update() # Save "last change" timestamp in django-tools SmoothCacheBackend
    except AttributeError:
        # No SmoothCacheBackend used -> clean the complete cache
        cache.clear()


comment_will_be_posted.connect(comment_will_be_posted_handler)
comment_was_posted.connect(comment_was_posted_handler)


@ensure_csrf_cookie
@check_request(APP_LABEL, "_get_form() error", must_post=False, must_ajax=True)
@render_to("pylucid_comments/comment_form.html")
def _get_form(request):
    """ Send the comment form to via AJAX request """
    try: