diff options
author | Magnus Hagander | 2011-06-14 17:48:48 +0000 |
---|---|---|
committer | Magnus Hagander | 2011-06-14 17:48:48 +0000 |
commit | f92709d2a62274bfc4bb4175a635cc4f0113160e (patch) | |
tree | 75d0db79e3077ad84a9a2213ab44d6d8562c965c /pgweb/docs/models.py | |
parent | d9e26b9518d73e9a385fd387ebeb6dc58b999409 (diff) |
Implement basic varnish purging
This allows all models inherited from PgModel to specify which
URLs to purge by either setting a field or defining a function
called purge_urls, at which point they will be purged whenever
the save signal is fired.
Also implements a form under /admin/purge/ that allows for manual
purging. This should probably be extended in the future to show
the status of the pgq slaves, but that will come later.
Includes a SQL function that posts the expires to a pgq queue. For
a local deployment, this can be replaced with a simple void function
to turn off varnish purging.
Diffstat (limited to 'pgweb/docs/models.py')
-rw-r--r-- | pgweb/docs/models.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pgweb/docs/models.py b/pgweb/docs/models.py index 931d868a..7295c69c 100644 --- a/pgweb/docs/models.py +++ b/pgweb/docs/models.py @@ -1,6 +1,7 @@ from django.db import models from django.contrib.auth.models import User from pgweb.util.bases import PgModel +from pgweb.core.models import Version from datetime import datetime @@ -24,6 +25,14 @@ class DocComment(PgModel, models.Model): send_notification = True + def purge_urls(self): + yield '/docs/%s/interactive/%s' % (self.version, self.file) + try: + if Version.objects.get(tree=self.version).current: + yield '/docs/current/interactive/%s' % self.file + except Version.DoesNotExist: + pass + class Meta: ordering = ('-posted_at',) |