diff --git a/.hgignore b/.hgignore index 0ff3e91..508637e 100644 --- a/.hgignore +++ b/.hgignore @@ -4,4 +4,6 @@ syntax: glob MANIFEST build dist -django_dbtemplates.egg-info/ \ No newline at end of file +django_dbtemplates.egg-info/ +example/example.db +docs/_build \ No newline at end of file diff --git a/.hgtags b/.hgtags index 45564df..e69f8c1 100644 --- a/.hgtags +++ b/.hgtags @@ -18,3 +18,4 @@ bf3db2fe192d4a02bf531e61e23df342c36d6b1b 0.5.1 ade167225d06cb6888ea8bfa84e7d020590171c6 0.5.6 dff01be9c8af328f8fcbc2fc97edcbe8d97840e2 0.5.7 f8f7eaf275c5e8ac52174642265af55691abef7c 0.5.8 +4b36382cdfd756f45f81b0d042aaf331c3eabe30 0.6.0 \ No newline at end of file diff --git a/LICENSE b/LICENSE index c0d146f..420c261 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2007-2009, Jannis Leidel +Copyright (c) 2007-2009, Jannis Leidel and contributors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index d7ecfb2..d1fc581 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,2 +1,2 @@ -VERSION = (0, 5, 8) +VERSION = (0, 6, 0) __version__ = '.'.join(map(str, VERSION)) \ No newline at end of file diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index b50b1c1..22ca016 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -1,9 +1,10 @@ from django import forms from django.conf import settings from django.contrib import admin -from django.utils.translation import gettext_lazy as _ +from django.utils.translation import ungettext, ugettext_lazy as _ -from dbtemplates.models import Template +from dbtemplates.models import Template, backend, remove_cached_template, \ + add_template_to_cache # Check if django-reversion is installed and use reversions' VersionAdmin # as the base admin class if yes @@ -40,6 +41,34 @@ class TemplateAdmin(TemplateModelAdmin): list_display = ('name', 'creation_date', 'last_changed', 'site_list') list_filter = ('sites',) search_fields = ('name', 'content') + if backend: + actions = ['invalidate_cache', 'repopulate_cache'] + + def invalidate_cache(self, request, queryset): + if not backend: + self.message_user(request, ("There is no active cache backend.")) + return + for template in queryset: + remove_cached_template(template) + message = ungettext( + "Cache of one template successfully invalidated.", + "Cache of %(count)d templates successfully invalidated.", + len(queryset)) + self.message_user(request, message % {'count': len(queryset)}) + invalidate_cache.short_description = _("Invalidate cache of selected templates") + + def repopulate_cache(self, request, queryset): + if not backend: + self.message_user(request, ("There is no active cache backend.")) + return + for template in queryset: + add_template_to_cache(template) + message = ungettext( + "Cache successfully repopulated with one template.", + "Cache successfully repopulated with %(count)d templates.", + len(queryset)) + self.message_user(request, message % {'count': len(queryset)}) + repopulate_cache.short_description = _("Repopulate cache with selected templates") def site_list(self, template): return ", ".join([site.name for site in template.sites.all()]) diff --git a/dbtemplates/locale/da/LC_MESSAGES/django.mo b/dbtemplates/locale/da/LC_MESSAGES/django.mo new file mode 100644 index 0000000..8acc570 Binary files /dev/null and b/dbtemplates/locale/da/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/da/LC_MESSAGES/django.po b/dbtemplates/locale/da/LC_MESSAGES/django.po new file mode 100644 index 0000000..f6ba713 --- /dev/null +++ b/dbtemplates/locale/da/LC_MESSAGES/django.po @@ -0,0 +1,84 @@ +# django-dbtemplates in Danish. +# django-dbtemplates på Dansk. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Michael Lind Mortensen , 2009. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin.py:29 +msgid "" +"Leaving this empty causes Django to look for a template with the given name " +"and populate this field with its content." +msgstr "" +"Hvis du efterlader dette felt tomt, så vil Django søge efter en template med " +"det givne navn og udfylde dette felt med dets indhold." + +#: admin.py:43 +msgid "Date/time" +msgstr "Dato/tid" + +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:65 +msgid "Invalidate cache of selected templates" +msgstr "" + +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:78 +msgid "Repopulate cache with selected templates" +msgstr "" + +#: admin.py:82 +msgid "sites" +msgstr "websider" + +#: models.py:18 +msgid "name" +msgstr "navn" + +#: models.py:19 +msgid "Example: 'flatpages/default.html'" +msgstr "Eksempel: 'flatpages/default.html'" + +#: models.py:20 +msgid "content" +msgstr "indhold" + +#: models.py:22 +msgid "creation date" +msgstr "oprettelsesdato" + +#: models.py:24 +msgid "last changed" +msgstr "sidst ændret" + +#: models.py:32 +msgid "template" +msgstr "skabelon" + +#: models.py:33 +msgid "templates" +msgstr "skabeloner" diff --git a/dbtemplates/locale/de/LC_MESSAGES/django.mo b/dbtemplates/locale/de/LC_MESSAGES/django.mo index 06721af..6e32001 100644 Binary files a/dbtemplates/locale/de/LC_MESSAGES/django.mo and b/dbtemplates/locale/de/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/de/LC_MESSAGES/django.po b/dbtemplates/locale/de/LC_MESSAGES/django.po index 497a13c..96f877a 100644 --- a/dbtemplates/locale/de/LC_MESSAGES/django.po +++ b/dbtemplates/locale/de/LC_MESSAGES/django.po @@ -1,8 +1,9 @@ +# msgid "" msgstr "" "Project-Id-Version: 0.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-03-01 00:56+0100\n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" "PO-Revision-Date: 2008-08-19 17:11+0100\n" "Last-Translator: Jannis Leidel \n" "Language-Team: Jannis Leidel \n" @@ -11,7 +12,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: German\n" -#: admin.py:21 +#: admin.py:29 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -19,38 +20,60 @@ msgstr "" "Wenn Sie dieses Feld leer lassen, wird Django versuchen, das Template mit " "dem angegebenen Namen zu finden und mit dessen Inhalt das Feld zu füllen." -#: admin.py:35 +#: admin.py:43 msgid "Date/time" -msgstr "" +msgstr "Datum/Uhrzeit" -#: admin.py:46 +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "Der Cache eines Templates wurde erfolgreich geleert." +msgstr[1] "Der Cache von %(count)d Templates wurde erfolgreich geleert." + +#: admin.py:65 +msgid "Invalidate cache of selected templates" +msgstr "Cache der ausgewählten Templates leeren" + +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "Der Cache eines Templates wurde erfolgreich geleert und neu gefüllt." +msgstr[1] "Der Cache von %(count)d Templates wurde erfolgreich geleert und neu gefüllt." + +#: admin.py:78 +msgid "Repopulate cache with selected templates" +msgstr "Cache der ausgewählten Templates neu füllen" + +#: admin.py:82 msgid "sites" -msgstr "" +msgstr "Seiten" #: models.py:18 msgid "name" msgstr "Name" -#: models.py:18 +#: models.py:19 msgid "Example: 'flatpages/default.html'" msgstr "Zum Beispiel: 'flatpages/default.html'" -#: models.py:19 +#: models.py:20 msgid "content" msgstr "Inhalt" -#: models.py:21 +#: models.py:22 msgid "creation date" msgstr "Erstellt" -#: models.py:22 +#: models.py:24 msgid "last changed" msgstr "Geändert" -#: models.py:29 +#: models.py:32 msgid "template" msgstr "Template" -#: models.py:30 +#: models.py:33 msgid "templates" msgstr "Templates" diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.mo b/dbtemplates/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 0000000..d9cde8b Binary files /dev/null and b/dbtemplates/locale/en/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/en/LC_MESSAGES/django.po b/dbtemplates/locale/en/LC_MESSAGES/django.po new file mode 100644 index 0000000..79e77d0 --- /dev/null +++ b/dbtemplates/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,81 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin.py:29 +msgid "" +"Leaving this empty causes Django to look for a template with the given name " +"and populate this field with its content." +msgstr "" + +#: admin.py:43 +msgid "Date/time" +msgstr "" + +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:65 +msgid "Invalidate cache of selected templates" +msgstr "" + +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:78 +msgid "Repopulate cache with selected templates" +msgstr "" + +#: admin.py:82 +msgid "sites" +msgstr "" + +#: models.py:18 +msgid "name" +msgstr "" + +#: models.py:19 +msgid "Example: 'flatpages/default.html'" +msgstr "" + +#: models.py:20 +msgid "content" +msgstr "" + +#: models.py:22 +msgid "creation date" +msgstr "" + +#: models.py:24 +msgid "last changed" +msgstr "" + +#: models.py:32 +msgid "template" +msgstr "" + +#: models.py:33 +msgid "templates" +msgstr "" diff --git a/dbtemplates/locale/fr/LC_MESSAGES/django.mo b/dbtemplates/locale/fr/LC_MESSAGES/django.mo index b923ef5..5b975da 100644 Binary files a/dbtemplates/locale/fr/LC_MESSAGES/django.mo and b/dbtemplates/locale/fr/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/fr/LC_MESSAGES/django.po b/dbtemplates/locale/fr/LC_MESSAGES/django.po index 7542d7c..a6e5e8f 100644 --- a/dbtemplates/locale/fr/LC_MESSAGES/django.po +++ b/dbtemplates/locale/fr/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-03-01 00:56+0100\n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" "PO-Revision-Date: 2008-08-09 21:39+0100\n" "Last-Translator: Roland Frédéric \n" "Language-Team: Frédéric Roland \n" @@ -11,17 +11,39 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: French\n" -#: admin.py:21 +#: admin.py:29 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "" -#: admin.py:35 +#: admin.py:43 msgid "Date/time" msgstr "" -#: admin.py:46 +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:65 +msgid "Invalidate cache of selected templates" +msgstr "" + +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:78 +msgid "Repopulate cache with selected templates" +msgstr "" + +#: admin.py:82 msgid "sites" msgstr "" @@ -29,26 +51,26 @@ msgstr "" msgid "name" msgstr "nom" -#: models.py:18 +#: models.py:19 msgid "Example: 'flatpages/default.html'" msgstr "Exemple: 'flatpages/default.html'" -#: models.py:19 +#: models.py:20 msgid "content" msgstr "contenu" -#: models.py:21 +#: models.py:22 msgid "creation date" msgstr "date de création" -#: models.py:22 +#: models.py:24 msgid "last changed" msgstr "dernier changement" -#: models.py:29 +#: models.py:32 msgid "template" msgstr "modèle" -#: models.py:30 +#: models.py:33 msgid "templates" msgstr "modèles" diff --git a/dbtemplates/locale/he/LC_MESSAGES/django.mo b/dbtemplates/locale/he/LC_MESSAGES/django.mo index f657673..857a7df 100644 Binary files a/dbtemplates/locale/he/LC_MESSAGES/django.mo and b/dbtemplates/locale/he/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/he/LC_MESSAGES/django.po b/dbtemplates/locale/he/LC_MESSAGES/django.po index 59051fd..b5fcf25 100644 --- a/dbtemplates/locale/he/LC_MESSAGES/django.po +++ b/dbtemplates/locale/he/LC_MESSAGES/django.po @@ -2,59 +2,81 @@ # Copyright (C) 2008 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # <>, 2008. -# , fuzzy # # +#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-03-01 00:56+0100\n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" "PO-Revision-Date: 2008-08-21 12:31+0300\n" -"Last-Translator: <>\n" +"Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: admin.py:21 +#: admin.py:29 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." msgstr "אם זה ריק אז ג'נגו מחפש תבנית עם שם סיפק וממלא את השדה עם תוכנו" -#: admin.py:35 +#: admin.py:43 msgid "Date/time" +msgstr "תאריך / זמן" + +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:65 +msgid "Invalidate cache of selected templates" msgstr "" -#: admin.py:46 -msgid "sites" +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:78 +msgid "Repopulate cache with selected templates" msgstr "" +#: admin.py:82 +msgid "sites" +msgstr "אתרים" + #: models.py:18 msgid "name" msgstr "שם" -#: models.py:18 +#: models.py:19 msgid "Example: 'flatpages/default.html'" msgstr "דוגמא: 'flatpages/default.html'" -#: models.py:19 +#: models.py:20 msgid "content" msgstr "תוכן" -#: models.py:21 +#: models.py:22 msgid "creation date" msgstr "נוצר ב" -#: models.py:22 +#: models.py:24 msgid "last changed" msgstr "שונה ב" -#: models.py:29 +#: models.py:32 msgid "template" msgstr "תבנית" -#: models.py:30 +#: models.py:33 msgid "templates" msgstr "תבניות" diff --git a/dbtemplates/locale/it/LC_MESSAGES/django.mo b/dbtemplates/locale/it/LC_MESSAGES/django.mo index b56c9fb..4070434 100644 Binary files a/dbtemplates/locale/it/LC_MESSAGES/django.mo and b/dbtemplates/locale/it/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/it/LC_MESSAGES/django.po b/dbtemplates/locale/it/LC_MESSAGES/django.po index 383a42a..7b93b58 100644 --- a/dbtemplates/locale/it/LC_MESSAGES/django.po +++ b/dbtemplates/locale/it/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-03-01 00:56+0100\n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" "PO-Revision-Date: 2009-01-22 01:27+0100\n" "Last-Translator: Marco Beri \n" "Language-Team: Jannis Leidel \n" @@ -11,7 +11,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: German\n" -#: admin.py:21 +#: admin.py:29 msgid "" "Leaving this empty causes Django to look for a template with the given name " "and populate this field with its content." @@ -19,11 +19,33 @@ msgstr "" "Lasciandolo vuoto, Django cercherà un template con lo stesso nome che avete " "indicato sopra e userà il suo contenuto per riempire questo campo." -#: admin.py:35 +#: admin.py:43 msgid "Date/time" msgstr "" -#: admin.py:46 +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:65 +msgid "Invalidate cache of selected templates" +msgstr "" + +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:78 +msgid "Repopulate cache with selected templates" +msgstr "" + +#: admin.py:82 msgid "sites" msgstr "" @@ -31,26 +53,26 @@ msgstr "" msgid "name" msgstr "nome" -#: models.py:18 +#: models.py:19 msgid "Example: 'flatpages/default.html'" msgstr "Esempio: 'flatpages/default.html'" -#: models.py:19 +#: models.py:20 msgid "content" msgstr "contenuto" -#: models.py:21 +#: models.py:22 msgid "creation date" msgstr "data di creazione" -#: models.py:22 +#: models.py:24 msgid "last changed" msgstr "ultimo cambiamento" -#: models.py:29 +#: models.py:32 msgid "template" msgstr "template" -#: models.py:30 +#: models.py:33 msgid "templates" msgstr "template" diff --git a/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo b/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo new file mode 100644 index 0000000..14e12f3 Binary files /dev/null and b/dbtemplates/locale/pt_BR/LC_MESSAGES/django.mo differ diff --git a/dbtemplates/locale/pt_BR/LC_MESSAGES/django.po b/dbtemplates/locale/pt_BR/LC_MESSAGES/django.po new file mode 100644 index 0000000..fea37ca --- /dev/null +++ b/dbtemplates/locale/pt_BR/LC_MESSAGES/django.po @@ -0,0 +1,78 @@ +# Diego Búrigo Zacarão 2009. +msgid "" +msgstr "" +"Project-Id-Version: 0.4\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-10-09 13:45+0200\n" +"PO-Revision-Date: 2008-08-31 11:45-0300\n" +"Last-Translator: Diego Búrigo Zacarão \n" +"Language-Team: Brazilian Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin.py:29 +msgid "" +"Leaving this empty causes Django to look for a template with the given name " +"and populate this field with its content." +msgstr "" +"Manter isto vazio faz com que o Django procure por um modelo (template) com " +"o dado nome e preencha este campo com o seu conteúdo" + +#: admin.py:43 +msgid "Date/time" +msgstr "Data/hora" + +#: admin.py:61 +#, python-format +msgid "Cache of one template successfully invalidated." +msgid_plural "Cache of %(count)d templates successfully invalidated." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:65 +msgid "Invalidate cache of selected templates" +msgstr "" + +#: admin.py:74 +#, python-format +msgid "Cache successfully repopulated with one template." +msgid_plural "Cache successfully repopulated with %(count)d templates." +msgstr[0] "" +msgstr[1] "" + +#: admin.py:78 +msgid "Repopulate cache with selected templates" +msgstr "" + +#: admin.py:82 +msgid "sites" +msgstr "sites" + +#: models.py:18 +msgid "name" +msgstr "Name" + +#: models.py:19 +msgid "Example: 'flatpages/default.html'" +msgstr "Exemplo: 'flatpages/default.html'" + +#: models.py:20 +msgid "content" +msgstr "conteúdo" + +#: models.py:22 +msgid "creation date" +msgstr "Data de criação" + +#: models.py:24 +msgid "last changed" +msgstr "ultima modificação" + +#: models.py:32 +msgid "template" +msgstr "modelo" + +#: models.py:33 +msgid "templates" +msgstr "modelos" diff --git a/dbtemplates/models.py b/dbtemplates/models.py index 0b93427..5853796 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -72,6 +72,7 @@ def add_template_to_cache(instance, **kwargs): Called via Django's signals to cache the templates, if the template in the database was added or changed. """ + remove_cached_template(instance) backend.save(instance.name, instance.content) def remove_cached_template(instance, **kwargs): @@ -82,6 +83,5 @@ def remove_cached_template(instance, **kwargs): backend.remove(instance.name) if backend: - signals.post_save.connect(remove_cached_template, sender=Template) signals.post_save.connect(add_template_to_cache, sender=Template) signals.pre_delete.connect(remove_cached_template, sender=Template) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..c7385f2 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# +# django-dbtemplates documentation build configuration file, created by +# sphinx-quickstart on Fri Oct 9 14:52:11 2009. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.txt' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'django-dbtemplates' +copyright = u'2009, Jannis Leidel' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.6.0' +# The full version, including alpha/beta/rc tags. +release = '0.6.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +html_title = "django-dbtemplates documentation" + +# A shorter title for the navigation bar. Default is the same as html_title. +html_short_title = "django-dbtemplates" + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'django-dbtemplatesdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'django-dbtemplates.tex', u'django-dbtemplates Documentation', + u'Jannis Leidel', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True diff --git a/docs/index.txt b/docs/index.txt index 6481551..4eef226 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -1,4 +1,3 @@ -================== django-dbtemplates ================== @@ -12,5 +11,6 @@ created in the database. Contents: .. toctree:: + :maxdepth: 2 - overview.txt + overview diff --git a/docs/overview.txt b/docs/overview.txt index 1a4443b..3883d6a 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -217,7 +217,8 @@ Short installation howto Management commands =================== -``dbtemplates`` comes with two `Django management commands`_ to be used with ``django-admin.py`` or ``manage.py``: +``dbtemplates`` comes with two `Django management commands`_ to be used with +``django-admin.py`` or ``manage.py``: * ``sync_templates`` @@ -231,6 +232,37 @@ Management commands .. _Django management commands: http://docs.djangoproject.com/en/dev/ref/django-admin/ +Admin actions +============= + +``dbtemplates`` provides two `admin actions`_ to be used with Django>=1.1. + +* ``invalidate_cache`` + + Invalidates the cache of the selected templates by calling the appropriate + cache backend methods. + +* ``repopulate_cache`` + + Repopulates the cache with selected templates by invalidating it first and + filling then after that. + +.. _admin actions: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/actions/#ref-contrib-admin-actions + +Changelog: +========== + +v0.6 (10-09-09): +---------------- + +* Updated and added locales (Danish, Brazilian Portuguese) + +* Fixes an ambiguity problem with the cache invalidation + +* Added ``invalidate_cache`` and ``repopulate_cache`` admin actions + +* Added Sphinx documentation + Support ======= diff --git a/example/settings.py b/example/settings.py index dc39774..ebdeeac 100644 --- a/example/settings.py +++ b/example/settings.py @@ -54,7 +54,7 @@ SECRET_KEY = 'e-%(1e1f8ar2v)_8d!%-75a2ag(w(ht*l%n-wts5$li!5=97)8' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', + 'django.template.loaders.eggs.load_template_source', 'dbtemplates.loader.load_template_source', ) @@ -81,9 +81,10 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.flatpages', 'dbtemplates', + #'reversion', ) # Uncomment the following two settings to use the file system cache backend. # It will cache in the directory "cache" inside the example project directory. -# DBTEMPLATES_CACHE_BACKEND = "dbtemplates.cache.FileSystemBackend" -# DBTEMPLATES_CACHE_DIR = "cache" +#DBTEMPLATES_CACHE_BACKEND = "dbtemplates.cache.FileSystemBackend" +#DBTEMPLATES_CACHE_DIR = "cache" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..98cef66 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +[egg_info] +#tag_build = dev + +[build_sphinx] +source-dir = docs/ +build-dir = docs/_build +all_files = 1 + +[upload_docs] +upload-dir = docs/_build/html