diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-10-01 17:55:59 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-10-01 17:55:59 -0400 |
| commit | 643701f1d30e1af70dbd4e99cf8e3b9517f74561 (patch) | |
| tree | 7470dcb58bff8288b161598f2132773f610c66d2 /mako/lookup.py | |
| parent | 5cd508ffe0d7eaadd6516fc35137c93d1d6577a9 (diff) | |
| download | external_python_mako-643701f1d30e1af70dbd4e99cf8e3b9517f74561.tar.gz external_python_mako-643701f1d30e1af70dbd4e99cf8e3b9517f74561.tar.bz2 external_python_mako-643701f1d30e1af70dbd4e99cf8e3b9517f74561.zip | |
- Template caching has been converted into a plugin
system, whereby the usage of Beaker is just the
default plugin. Template and TemplateLookup
now accept a string "cache_impl" parameter which
refers to the name of a cache plugin, defaulting
to the name 'beaker'. New plugins can be
registered as pkg_resources entrypoints under
the group "mako.cache", or registered directly
using mako.cache.register_plugin(). The
core plugin is the mako.cache.CacheImpl
class.
- The <%def>, <%block> and <%page> tags now accept
any argument named "cache_*", and the key
minus the "cache_" prefix will be passed as keyword
arguments to the CacheImpl methods.
- Template and TemplateLookup now accept an argument
cache_args, which refers to a dictionary containing
cache parameters. The cache_dir, cache_url, cache_type,
cache_timeout arguments are deprecated (will probably
never be removed, however) and can be passed
now as cache_args={'url':<some url>, 'type':'memcached',
'timeout':50, 'dir':'/path/to/some/directory'}
Diffstat (limited to 'mako/lookup.py')
| -rw-r--r-- | mako/lookup.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/mako/lookup.py b/mako/lookup.py index e3d92da..c2fb034 100644 --- a/mako/lookup.py +++ b/mako/lookup.py @@ -151,9 +151,14 @@ class TemplateLookup(TemplateCollection): bytestring_passthrough=False, output_encoding=None, encoding_errors='strict', + + cache_args=None, + cache_impl='beaker', + cache_enabled=True, cache_type=None, - cache_dir=None, cache_url=None, - cache_enabled=True, + cache_dir=None, + cache_url=None, + modulename_callable=None, default_filters=None, buffer_filters=(), @@ -170,6 +175,16 @@ class TemplateLookup(TemplateCollection): self.filesystem_checks = filesystem_checks self.collection_size = collection_size + if cache_args is None: + cache_args = {} + # transfer deprecated cache_* args + if cache_dir: + cache_args.setdefault('dir', cache_dir) + if cache_url: + cache_args.setdefault('url', cache_url) + if cache_type: + cache_args.setdefault('type', cache_type) + self.template_args = { 'format_exceptions':format_exceptions, 'error_handler':error_handler, @@ -179,9 +194,7 @@ class TemplateLookup(TemplateCollection): 'encoding_errors':encoding_errors, 'input_encoding':input_encoding, 'module_directory':module_directory, - 'cache_type':cache_type, - 'cache_dir':cache_dir or module_directory, - 'cache_url':cache_url, + 'cache_args':cache_args, 'cache_enabled':cache_enabled, 'default_filters':default_filters, 'buffer_filters':buffer_filters, |
