From 9f0d7a2564ab0e5a5c13a1e87901f7a09603fa74 Mon Sep 17 00:00:00 2001 From: leidel Date: Sun, 2 Nov 2008 00:05:48 +0000 Subject: [PATCH] Fixed docstring in template loader. Fixed wrong return types in FileSystemBackend. git-svn-id: https://django-dbtemplates.googlecode.com/svn/trunk@59 cfb8ba98-e953-0410-9cff-959ffddf5974 committer: leidel --HG-- extra : convert_revision : 7ea05e043c43c23fbf846bc9ddd80400519631e2 --- dbtemplates/cache.py | 4 ++-- dbtemplates/loader.py | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dbtemplates/cache.py b/dbtemplates/cache.py index 5f5c709..9a481f2 100644 --- a/dbtemplates/cache.py +++ b/dbtemplates/cache.py @@ -62,7 +62,7 @@ class FileSystemBackend(BaseCacheBackend): self.cache_dir = getattr(settings, 'DBTEMPLATES_CACHE_DIR', None) self.cache_dir = os.path.normpath(self.cache_dir) if not os.path.isdir(self.cache_dir): - raise Exception + pass except: raise ImproperlyConfigured('You\'re using the dbtemplates\' file system cache backend without having set the DBTEMPLATES_CACHE_DIR setting to a valid value. Make sure the directory exists and is writeable for the user your Django instance is running with.') super(FileSystemBackend, self).__init__() @@ -75,7 +75,7 @@ class FileSystemBackend(BaseCacheBackend): filepath = self._filepath(name) return open(filepath).read().decode('utf-8') except: - raise None + return None def save(self, name, content, retry=False): try: diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index a5421ab..2503091 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -7,12 +7,10 @@ from dbtemplates.models import Template, backend def load_template_source(template_name, template_dirs=None): """ - Tries to load the template from DBTEMPLATES_CACHE_DIR. If it does not - exist loads templates from the database by querying the database field - ``name`` with a template path and ``sites`` with the current site, - and tries to save the template as DBTEMPLATES_CACHE_DIR/``name`` for - subsequent requests. If DBTEMPLATES_CACHE_DIR is not configured falls - back to database-only operation. + Tries to load the template from the dbtemplates cache backend specified + by the DBTEMPLATES_CACHE_BACKEND setting. If it does not find a template + it falls back to query the database field ``name`` with the template path + and ``sites`` with the current site. """ display_name = 'db:%s:%s' % (settings.DATABASE_ENGINE, template_name) if backend: