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)
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)
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)
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)
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
def delete_index(sender, instance): quick_delete(instance, '/')
def publish_comment(sender, instance): quick_delete(instance.get_content_object())
def unpublish_blog(sender, **kwargs): instance = kwargs.get('instance') quick_delete('/blog/%i/' % instance.id) quick_publish('/')
def delete(sender, instance, **kwargs): quick_delete(instance, '/')
def invalidate_robots(**kwargs): quick_delete('/robots.txt')
def invalidate_img(instance, **kwargs): quick_delete('/') quick_delete('home/')
def invalidate_gallery(instance, **kwargs): quick_delete('gallery/')
def invalidate_service(instance, **kwargs): quick_delete('services/')
def invalidate_cms(instance, **kwargs): quick_delete('/')