comparison decoupage/web.py @ 96:21273cdb2047

minor polish
author Jeff Hammel <k0scist@gmail.com>
date Sun, 21 Aug 2016 19:46:00 -0700
parents c5895d87c65e
children abf23c2e4e82
comparison
equal deleted inserted replaced
95:c0f6a87d4dd8 96:21273cdb2047
32 from pkg_resources import resource_filename 32 from pkg_resources import resource_filename
33 from webob import Request, Response, exc 33 from webob import Request, Response, exc
34 34
35 transformers = transformers() 35 transformers = transformers()
36 string = (str, unicode) 36 string = (str, unicode)
37
37 38
38 class Decoupage(object): 39 class Decoupage(object):
39 40
40 ### class level variables 41 ### class level variables
41 defaults = { 'auto_reload': False, 42 defaults = { 'auto_reload': False,
118 119
119 120
120 ### methods dealing with HTTP 121 ### methods dealing with HTTP
121 122
122 def __call__(self, environ, start_response): 123 def __call__(self, environ, start_response):
124 """WSGI application"""
123 125
124 # boilerplate: request and filename 126 # boilerplate: request and filename
125 request = Request(environ) 127 request = Request(environ)
126 filename = request.path_info.strip('/') 128 filename = request.path_info.strip('/')
127 path = os.path.join(self.directory, filename) 129 path = os.path.join(self.directory, filename)
179 conf = self.conf(path) 181 conf = self.conf(path)
180 182
181 ### build data dictionary 183 ### build data dictionary
182 # TODO: separate these out into several formatters 184 # TODO: separate these out into several formatters
183 files = self.filedata(path, directory, conf) 185 files = self.filedata(path, directory, conf)
184 data = {'path': path, 'files': files, 'request': request } 186 data = {'path': path, 'files': files, 'request': request}
185 187
186 # add a function to get the path to files 188 # add a function to get the path to files
187 data['filepath'] = lambda *segments: os.path.join(*([directory] + list(segments))) 189 data['filepath'] = lambda *segments: os.path.join(*([directory] + list(segments)))
188 190
189 # defaults 191 # defaults