Mercurial > hg > decoupage
changeset 96:21273cdb2047
minor polish
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 21 Aug 2016 19:46:00 -0700 |
parents | c0f6a87d4dd8 |
children | a31de0eaf565 |
files | decoupage.ini decoupage/web.py paster-serve.ini |
diffstat | 2 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/decoupage/web.py +++ b/decoupage/web.py @@ -30,16 +30,17 @@ from paste.fileapp import FileApp from pkg_resources import iter_entry_points from pkg_resources import load_entry_point from pkg_resources import resource_filename from webob import Request, Response, exc transformers = transformers() string = (str, unicode) + class Decoupage(object): ### class level variables defaults = { 'auto_reload': False, 'configuration': None, 'directory': None, # directory to serve 'cascade': True, # whether to cascade configuration 'template': 'index.html', # XXX see below @@ -115,16 +116,17 @@ class Decoupage(object): self.loader = TemplateLoader(self.template_directories, variable_lookup="lenient", auto_reload=self.auto_reload) ### methods dealing with HTTP def __call__(self, environ, start_response): + """WSGI application""" # boilerplate: request and filename request = Request(environ) filename = request.path_info.strip('/') path = os.path.join(self.directory, filename) # check to see what we have to serve if os.path.exists(path): @@ -176,17 +178,17 @@ class Decoupage(object): path = '/%s' % path # get the configuraton conf = self.conf(path) ### build data dictionary # TODO: separate these out into several formatters files = self.filedata(path, directory, conf) - data = {'path': path, 'files': files, 'request': request } + data = {'path': path, 'files': files, 'request': request} # add a function to get the path to files data['filepath'] = lambda *segments: os.path.join(*([directory] + list(segments))) # defaults data['directory'] = directory data['css'] = () data['scripts'] = ()