Example #1
0
def delete_blog_index(sender, instance, **kwargs):
    """
    Delete all files in the StaticGenerator cache that will be
    out-of-date after a blog entry is saved.  These are:

      * About page (it has links to the three most-recent entries)
      * Blog index
      * Archive page for the year the entry was published
      * Admin users' preview page
      * Blog Atom 1.0 feed
      * Page for the blog entry itself
      * Previously published entry's page
      * Next published entry's page
    """
    stagnant_cache_urls = [
        "/about/",
        reverse("blog_entry_index"),
        reverse("blog_entry_archive_year", args=[instance.published_at.year]),
        reverse("blog_entry_preview", args=[instance.published_at.year, instance.slug]),
        reverse("blog_feeds"),
        instance.get_absolute_url(),
    ]
    try:
        stagnant_cache_urls.append(instance.get_next_published_entry())
    except ObjectDoesNotExist:
        pass
    try:
        stagnant_cache_urls.append(instance.get_previous_published_entry())
    except ObjectDoesNotExist:
        pass
    quick_delete(*stagnant_cache_urls)
Example #2
0
def delete_blog_index(sender, instance, **kwargs):
    """
    Delete all files in the StaticGenerator cache that will be
    out-of-date after a blog entry is saved.  These are:

      * About page (it has links to the three most-recent entries)
      * Blog index
      * Archive page for the year the entry was published
      * Admin users' preview page
      * Blog Atom 1.0 feed
      * Page for the blog entry itself
      * Previously published entry's page
      * Next published entry's page
    """
    stagnant_cache_urls = [
        '/about/',
        reverse('blog_entry_index'),
        reverse('blog_entry_archive_year', args=[instance.published_at.year]),
        reverse('blog_entry_preview',
                args=[instance.published_at.year, instance.slug]),
        reverse('blog_feeds', args=['latest']),
        instance.get_absolute_url(),
    ]
    try:
        stagnant_cache_urls.append(instance.get_next_published_entry())
    except ObjectDoesNotExist:
        pass
    try:
        stagnant_cache_urls.append(instance.get_previous_published_entry())
    except ObjectDoesNotExist:
        pass
    quick_delete(*stagnant_cache_urls)
Example #3
0
def clear_stagnant_cache_on_comment_change(sender, instance, **kwargs):
    """
    Delete the files in the StaticGenerator cache that will be
    out-of-date after a comment is saved or deleted.  These are:

      * Blog index (if this is dealing with the most recent entry)
      * Blog entry page

    Note however that if this is a new comment marked as spam (i.e. the
    ``is_public`` field is False) the cache will not be deleted
    """
    created = kwargs.get("created", False)
    if (not created) or (created and instance.is_public):
        stagnant_cache_urls = [instance.content_object.get_absolute_url()]
        try:
            instance.content_object.get_next_published_entry()
        except ObjectDoesNotExist:
            # This is the most recent entry in the blog so the blog
            # index will need to be removed from the cache.
            stagnant_cache_urls.append(reverse("blog_entry_index"))
        quick_delete(*stagnant_cache_urls)
Example #4
0
def clear_stagnant_cache_on_comment_change(sender, instance, **kwargs):
    """
    Delete the files in the StaticGenerator cache that will be
    out-of-date after a comment is saved or deleted.  These are:

      * Blog index (if this is dealing with the most recent entry)
      * Blog entry page

    Note however that if this is a new comment marked as spam (i.e. the
    ``is_public`` field is False) the cache will not be deleted
    """
    created = kwargs.get('created', False)
    if (not created) or (created and instance.is_public):
        stagnant_cache_urls = [instance.content_object.get_absolute_url()]
        try:
            instance.content_object.get_next_published_entry()
        except ObjectDoesNotExist:
            # This is the most recent entry in the blog so the blog
            # index will need to be removed from the cache.
            stagnant_cache_urls.append(reverse('blog_entry_index'))
        quick_delete(*stagnant_cache_urls)
Example #5
0
 def clear_cache():
     """
     Clears the cache, might be used also by scripts like snmp.py (in nodeshot/scripts/)
     This function can be used also outside of signals
     """
     quick_delete('/')
     quick_delete('nodes.json')
     quick_delete('jstree.json')
     quick_delete('nodes.kml')
     quick_delete('overview/')
     quick_delete('tab3/')
     quick_delete('tab4/')
     try:
         shutil.rmtree('%s/select/' % WEB_ROOT)
     except OSError:
         pass
     try:
         shutil.rmtree('%s/node/' % WEB_ROOT)
     except OSError:
         pass
     try:
         shutil.rmtree('%s/search/' % WEB_ROOT)
     except OSError:
         pass
Example #6
0
 def clear_cache():
     """
     Clears the cache, might be used also by scripts like snmp.py (in nodeshot/scripts/)
     This function can be used also outside of signals
     """
     quick_delete('/')
     quick_delete('nodes.json')
     quick_delete('jstree.json')
     quick_delete('nodes.kml')
     quick_delete('overview/')
     quick_delete('tab3/')
     quick_delete('tab4/')
     try:
         shutil.rmtree('%s/select/' % WEB_ROOT)
     except OSError:
         pass
     try:
         shutil.rmtree('%s/node/' % WEB_ROOT)
     except OSError:
         pass
     try:
         shutil.rmtree('%s/search/' % WEB_ROOT)
     except OSError:
         pass
Example #7
0
def delete_index(sender, instance):
    quick_delete(instance, '/')
Example #8
0
def publish_comment(sender, instance):
    quick_delete(instance.get_content_object())
Example #9
0
def unpublish_blog(sender, **kwargs):
    instance = kwargs.get('instance')
    quick_delete('/blog/%i/' % instance.id)
    quick_publish('/')
Example #10
0
 def delete(sender, instance, **kwargs):
     quick_delete(instance, '/')
Example #11
0
def invalidate_robots(**kwargs):
	quick_delete('/robots.txt')
Example #12
0
def invalidate_img(instance, **kwargs):
	quick_delete('/')
	quick_delete('home/')
Example #13
0
def invalidate_gallery(instance, **kwargs):
	quick_delete('gallery/')
Example #14
0
def invalidate_service(instance, **kwargs):
	quick_delete('services/')
Example #15
0
def invalidate_cms(instance, **kwargs):
	quick_delete('/')