Mercurial > hg > genshi_view
changeset 18:24cd9c7749ce
* allow multiple template dirs
* allow endpoint app if used in middleware
author | k0s <k0scist@gmail.com> |
---|---|
date | Sun, 27 Dec 2009 16:44:26 -0500 |
parents | 4a9ceda73d92 |
children | 4a5b542a638c |
files | genshi_view/template/+package+/dispatcher.py setup.py |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi_view/template/+package+/dispatcher.py Fri Nov 20 16:42:57 2009 -0500 +++ b/genshi_view/template/+package+/dispatcher.py Sun Dec 27 16:44:26 2009 -0500 @@ -16,6 +16,8 @@ ### class level variables defaults = { 'auto_reload': 'False', + 'template_dirs': '', + 'app': None, 'name': 'anonymous' } def __init__(self, **kw): @@ -28,9 +30,14 @@ # request handlers self.handlers = [ Index ] + # endpoint app if used as middleware + if self.app: + assert hasattr(self.app, '__call__') + # template loader - templates_dir = resource_filename(__name__, 'templates') - self.loader = TemplateLoader(templates_dir, + self.template_dirs = self.template_dirs.split() + self.template_dirs.append(resource_filename(__name__, 'templates')) + self.loader = TemplateLoader(self.template_dirs, auto_reload=self.auto_reload) def __call__(self, environ, start_response): @@ -50,6 +57,8 @@ if handler is not None: break else: + if self.app: + return self.app(environ, start_response) handler = exc.HTTPNotFound # add navigation links to handler [example]