Mercurial > cgi-bin > hgweb.cgi > tincan
annotate tincan.py @ 1:94b36e721500 draft
Another check in to back stuff up.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 12 May 2019 19:19:40 -0700 |
parents | e726fafcffac |
children | ca6f8ca38cf2 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | |
3 # As with Bottle, it's all in one big, ugly file. For now. | |
4 | |
5 # I m p o r t s | |
6 | |
7 import os, sys | |
8 import ast | |
9 import binascii | |
10 from base64 import b16encode, b16decode | |
11 import importlib, py_compile | |
12 import io | |
13 | |
14 import bottle | |
15 | |
16 # C l a s s e s | |
17 | |
18 # Exceptions | |
19 | |
20 class TinCanException(Exception): | |
21 """ | |
22 The parent class of all exceptions we raise. | |
23 """ | |
24 pass | |
25 | |
26 class TemplateHeaderException(TinCanException): | |
27 """ | |
28 Raised upon encountering a syntax error in the template headers. | |
29 """ | |
30 def __init__(self, message, line): | |
31 super().__init__(message, line) | |
32 self.message = message | |
33 self.line = line | |
34 | |
35 def __str__(self): | |
36 return "Line {0}: {1}".format(self.line, self.message) | |
37 | |
38 class ForwardException(TinCanException): | |
39 """ | |
40 Raised to effect the flow control needed to do a forward (server-side | |
41 redirect). It is ugly to do this, but other Python frameworks do and | |
42 there seems to be no good alternative. | |
43 """ | |
44 def __init__(self, target): | |
45 self.target = target | |
46 | |
47 class TinCanError(TinCanException): | |
48 """ | |
49 General-purpose exception thrown by TinCan when things go wrong, often | |
50 when attempting to launch webapps. | |
51 """ | |
52 pass | |
53 | |
54 # Template (.pspx) files. These are standard templates for a supported | |
55 # template engine, but with an optional set of header lines that begin | |
56 # with '#'. | |
57 | |
58 class TemplateFile(object): | |
59 """ | |
60 Parse a template file into a header part and the body part. The header | |
61 is always a leading set of lines, each starting with '#', that is of the | |
62 same format regardless of the template body. The template body varies | |
63 depending on the selected templating engine. The body part has | |
64 each header line replaced by a blank line. This preserves the overall | |
65 line numbering when processing the body. The added newlines are normally | |
66 stripped out before the rendered page is sent back to the client. | |
67 """ | |
68 def __init__(self, raw, encoding='utf-8'): | |
69 if isinstance(raw, io.TextIOBase): | |
70 self._do_init(raw) | |
71 elif isinstance(raw, str): | |
72 with open(raw, "r", encoding=encoding) as fp: | |
73 self._do_init(fp) | |
74 else: | |
75 raise TypeError("Expecting a string or Text I/O object.") | |
76 | |
77 def _do_init(self, fp): | |
78 self._hbuf = [] | |
79 self._bbuf = [] | |
80 self._state = self._header | |
81 while True: | |
82 line = fp.readline() | |
83 if line == '': | |
84 break | |
85 self._state(line) | |
86 self.header = ''.join(self._hbuf) | |
87 self.body = ''.join(self._bbuf) | |
88 | |
89 def _header(self, line): | |
90 if not line.startswith('#'): | |
91 self._state = self._body | |
92 self._state(line) | |
93 return | |
94 self._hbuf.append(line) | |
95 self._bbuf.append("\n") | |
96 | |
97 def _body(self, line): | |
98 self._bbuf.append(line) | |
99 | |
100 class TemplateHeader(object): | |
101 """ | |
102 Parses and represents a set of header lines. | |
103 """ | |
104 _NAMES = [ "error", "forward", "methods", "python", "template" ] | |
105 _FNAMES = [ "hidden" ] | |
106 | |
107 def __init__(self, string): | |
108 # Initialize our state | |
109 for i in self._NAMES: | |
110 setattr(self, i, None) | |
111 for i in self._FNAMES: | |
112 setattr(self, i, False) | |
113 # Parse the string | |
114 count = 0 | |
115 nameset = set(self._NAMES + self._FNAMES) | |
116 seen = set() | |
117 lines = string.split("\n") | |
118 if lines and lines[-1] == "": | |
119 del lines[-1] | |
120 for line in lines: | |
121 # Get line | |
122 count += 1 | |
123 if not line.startswith("#"): | |
124 raise TemplateHeaderException("Does not start with '#'.", count) | |
125 try: | |
126 rna, rpa = line.split(maxsplit=1) | |
127 except ValueError: | |
128 raise TemplateHeaderException("Missing parameter.", count) | |
129 # Get name, ignoring remarks. | |
130 name = rna[1:] | |
131 if name == "rem": | |
132 continue | |
133 if name not in nameset: | |
134 raise TemplateHeaderException("Invalid directive: {0!r}".format(rna), count) | |
135 if name in seen: | |
136 raise TemplateHeaderException("Duplicate {0!r} directive.".format(rna), count) | |
137 seen.add(name) | |
138 # Flags | |
139 if name in self._FLAGS: | |
140 setattr(self, name, True) | |
141 continue | |
142 # Get parameter | |
143 param = rpa.strip() | |
144 for i in [ "'", '"']: | |
145 if param.startswith(i) and param.endswith(i): | |
146 param = ast.literal_eval(param) | |
147 break | |
148 # Update this object | |
149 setattr(self, name, param) | |
150 | |
151 # Support for Chameleon templates (the kind TinCan uses by default). | |
152 | |
153 class ChameleonTemplate(bottle.BaseTemplate): | |
154 def prepare(self, **options): | |
155 from chameleon import PageTemplate, PageTemplateFile | |
156 if self.source: | |
157 self.tpl = chameleon.PageTemplate(self.source, | |
158 encoding=self.encoding, **options) | |
159 else: | |
160 self.tpl = chameleon.PageTemplateFile(self.filename, | |
161 encoding=self.encoding, search_path=self.lookup, **options) | |
162 | |
163 def render(self, *args, **kwargs): | |
164 for dictarg in args: | |
165 kwargs.update(dictarg) | |
166 _defaults = self.defaults.copy() | |
167 _defaults.update(kwargs) | |
168 return self.tpl.render(**_defaults) | |
169 | |
170 chameleon_template = functools.partial(template, template_adapter=ChameleonTemplate) | |
171 chameleon_view = functools.partial(view, template_adapter=ChameleonTemplate) | |
172 | |
173 # Utility functions, used in various places. | |
174 | |
175 def _normpath(base, unsplit): | |
176 """ | |
177 Split, normalize and ensure a possibly relative path is absolute. First | |
178 argument is a list of directory names, defining a base. Second | |
179 argument is a string, which may either be relative to that base, or | |
180 absolute. Only '/' is supported as a separator. | |
181 """ | |
182 scratch = unsplit.strip('/').split('/') | |
183 if not unsplit.startswith('/'): | |
184 scratch = base + scratch | |
185 ret = [] | |
186 for i in scratch: | |
187 if i == '.': | |
188 continue | |
189 if i == '..': | |
190 ret.pop() # may raise IndexError | |
191 continue | |
192 ret.append(i) | |
193 return ret | |
194 | |
195 def _mangle(string): | |
196 """ | |
197 Turn a possibly troublesome identifier into a mangled one. | |
198 """ | |
199 first = True | |
200 ret = [] | |
201 for ch in string: | |
202 if ch == '_' or not (ch if first else "x" + ch).isidentifier(): | |
203 ret.append('_') | |
204 ret.append(b16encode(ch.encode("utf-8")).decode("us-ascii")) | |
205 else: | |
206 ret.append(ch) | |
207 first = False | |
208 return ''.join(ret) | |
209 | |
210 # The TinCan class. Simply a Bottle webapp that contains a forward method, so | |
211 # the code-behind can call request.app.forward(). | |
212 | |
213 class TinCan(bottle.Bottle): | |
214 def forward(self, target): | |
215 """ | |
216 Forward this request to the specified target route. | |
217 """ | |
218 source = bottle.request.environ['PATH_INFO'] | |
219 base = source.strip('/').split('/')[:-1] | |
220 try: | |
221 exc = ForwardException('/' + '/'.join(_normpath(base, target))) | |
222 except IndexError as e: | |
223 raise TinCanError("{0}: invalid forward to {1!r}".format(source, target)) from e | |
224 raise exc | |
225 | |
226 # Represents the code-behind of one of our pages. This gets subclassed, of | |
227 # course. | |
228 | |
229 class Page(object): | |
230 # Non-private things we refuse to export anyhow. | |
231 __HIDDEN = set([ "request", "response" ]) | |
232 | |
233 def __init__(self, req, resp): | |
234 """ | |
235 Constructor. This is a lightweight operation. | |
236 """ | |
237 self.request = req # app context is request.app in Bottle | |
238 self.response = resp | |
239 | |
240 def handle(self): | |
241 """ | |
242 This is the entry point for the code-behind logic. It is intended | |
243 to be overridden. | |
244 """ | |
245 pass | |
246 | |
247 def export(self): | |
248 """ | |
249 Export template variables. The default behavior is to export all | |
250 non-hidden non-callables that don't start with an underscore, | |
251 plus a an export named page that contains this object itself. | |
252 This method can be overridden if a different behavior is | |
253 desired. It should always return a dict or dict-like object. | |
254 """ | |
255 ret = { "page": self } # feature: will be clobbered if self.page exists | |
256 for name in dir(self): | |
257 if name in self.__HIDDEN or name.startswith('_'): | |
258 continue | |
259 value = getattr(self, name) | |
260 if callable(value): | |
261 continue | |
262 ret[name] = value | |
263 | |
264 # Represents a route in TinCan. Our launcher creates these on-the-fly based | |
265 # on the files it finds. | |
266 | |
1
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
267 EXTENSION = ".pspx" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
268 CONTENT = "text/html" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
269 _WINF = "WEB-INF" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
270 _BANNED = set([_WINF]) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
271 _CODING = "utf-8" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
272 _CLASS = "Page" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
273 _FLOOP = "tincan.forwards" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
274 _FORIG = "tincan.origin" |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
275 |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
276 class TinCanErrorRoute(object): |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
277 """ |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
278 A route to an error page. These never have code-behind, don't get |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
279 routes created for them, and are only reached if an error routes them |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
280 there. Error templates only have two variables available: e (the |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
281 HTTPError object associated with the error) and request. |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
282 """ |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
283 def __init__(self, template): |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
284 self._template = template |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
285 self._template.prepare() |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
286 |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
287 def __call__(self, e): |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
288 return self._template.render(e=e, request=bottle.request).lstrip('\n') |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
289 |
0 | 290 class TinCanRoute(object): |
291 """ | |
292 A route created by the TinCan launcher. | |
293 """ | |
294 def __init__(self, launcher, name, subdir): | |
295 self._plib = launcher.plib | |
296 self._fsroot = launcher.fsroot | |
297 self._urlroot = launcher.urlroot | |
298 self._name = name | |
299 self._python = name + ".py" | |
300 self._content = CONTENT | |
301 self._fspath = os.path.join(launcher.fsroot, *subdir, name + EXTENSION) | |
302 self._urlpath = self._urljoin(launcher.urlroot, *subdir, name + EXTENSION) | |
303 self._origin = self._urlpath | |
304 self._subdir = subdir | |
305 self._seen = set() | |
306 self._class = None | |
307 self._tclass = launcher.tclass | |
308 self._app = launcher.app | |
309 | |
310 def launch(self, config): | |
311 """ | |
312 Launch a single page. | |
313 """ | |
314 # Build master and header objects, process #forward directives | |
315 hidden = None | |
316 while True: | |
317 self._template = TemplateFile(self._fspath) | |
318 self._header = TemplateHeader(self._template.header) | |
319 if hidden is None: | |
320 hidden = self._header.hidden | |
321 if self._header.forward is None: | |
322 break | |
323 self._redirect() | |
324 # If this is a hidden page, we ignore it for now, since hidden pages | |
325 # don't get routes made for them. | |
326 if hidden: | |
327 return | |
1
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
328 # If this is an error page, register it as such. |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
329 if self._header.error is not None: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
330 try: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
331 errors = [ int(i) for i in self._header.error.split() ] |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
332 except ValueError as e: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
333 raise TinCanError("{0}: bad #error line".format(self._urlpath)) from e |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
334 if not errors: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
335 errors = range(400, 600) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
336 route = TinCanErrorRoute(self._tclass(source=self._template.body)) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
337 for error in errors: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
338 self._app.error(code=error, callback=route) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
339 return # this implies #hidden |
0 | 340 # Get methods for this route |
341 if self._header.methods is None: | |
342 methods = [ 'GET' ] | |
343 else: | |
344 methods = [ i.upper() for i in self._header.methods.split() ] | |
345 # Process other header entries | |
346 if self._header.python is not None: | |
347 if not self._header.python.endswith('.py'): | |
348 raise TinCanError("{0}: #python files must end in .py", self._urlpath) | |
349 self._python = self._header.python | |
350 # Obtain a class object by importing and introspecting a module. | |
351 pypath = os.path.normpath(os.path.join(self._fsroot, *self._subdir, self._python)) | |
352 pycpath = pypath + 'c' | |
353 try: | |
354 pyctime = os.stat(pycpath).st_mtime | |
355 except OSError: | |
356 pyctime = 0 | |
357 if pyctime < os.stat(pypath).st_mtime: | |
358 try: | |
359 py_compile.compile(pypath, cfile=pycpath) | |
360 except Exception as e: | |
361 raise TinCanError("{0}: error compiling".format(pypath)) from e | |
362 try: | |
363 self._mangled = self._manage_module() | |
364 spec = importlib.util.spec_from_file_location(_mangle(self._name), cpath) | |
365 mod = importlib.util.module_from_spec(spec) | |
366 spec.loader.exec_module(mod) | |
367 except Exception as e: | |
368 raise TinCanError("{0}: error importing".format(pycpath)) from e | |
369 self._class = None | |
370 for i in dir(mod): | |
371 v = getattr(mod, i) | |
372 if issubclass(v, Page): | |
373 if self._class is not None: | |
374 raise TinCanError("{0}: contains multiple Page classes", pypath) | |
375 self._class = v | |
376 # Build body object (Chameleon template) | |
1
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
377 if self._header.template is not None: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
378 tpath = os.path.join(self._fsroot, *self._splitpath(self._header.template)) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
379 tfile = TemplateFile(tpath) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
380 self._body = self._tclass(source=tfile.body) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
381 else: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
382 self._body = self._tclass(source=self._template.body) |
0 | 383 self._body.prepare() |
384 # Register this thing with Bottle | |
385 print("adding route:", self._origin) # debug | |
386 self._app.route(self._origin, methods, self) | |
387 | |
388 def _splitpath(self, unsplit): | |
389 return _normpath(self._subdir, unsplit) | |
390 | |
391 def _redirect(self): | |
392 if self._header.forward in self._seen: | |
393 raise TinCanError("{0}: #forward loop".format(self._origin)) | |
394 self._seen.add(self._header.forward) | |
395 try: | |
396 rlist = self._splitpath(self._header.forward) | |
397 rname = rlist.pop() | |
398 except IndexError as e: | |
399 raise TinCanError("{0}: invalid #forward".format(self._urlpath)) from e | |
400 name, ext = os.path.splitext(rname)[1] | |
401 if ext != EXTENSION: | |
402 raise TinCanError("{0}: invalid #forward".format(self._urlpath)) | |
403 self._subdir = rlist | |
404 self._python = name + ".py" | |
405 self._fspath = os.path.join(self._fsroot, *self._subdir, rname) | |
406 self._urlpath = self._urljoin(*self._subdir, rname) | |
407 | |
408 def _urljoin(self, *args): | |
409 args = list(args) | |
410 if args[0] == '/': | |
411 args[0] = '' | |
412 return '/'.join(args) | |
413 | |
1
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
414 def __call__(self): |
0 | 415 """ |
416 This gets called by the framework AFTER the page is launched. | |
417 """ | |
1
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
418 target = None |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
419 try: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
420 obj = self._class(bottle.request, bottle.response) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
421 obj.handle() |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
422 return self._body.render(obj.export()) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
423 except ForwardException as fwd: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
424 target = fwd.target |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
425 if target is None: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
426 raise TinCanError("Unexpected null target!") |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
427 # We get here if we are doing a server-side programmatic |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
428 # forward. |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
429 environ = bottle.request.environ |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
430 if _FLOOP not in environ: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
431 environ[_FLOOP] = set() |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
432 if _FORIG not in environ: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
433 environ[_FORIG] = self._urlpath |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
434 elif target in environ[_FLOOP]: |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
435 TinCanError("{0}: forward loop detected".format(environ[_FORIG])) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
436 environ[_FLOOP].add(target) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
437 environ['bottle.raw_path'] = target |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
438 environ['PATH_INFO'] = urllib.parse.quote(target) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
439 route, args = self._app.router.match(environ) |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
440 environ['route.handle'] = environ['bottle.route'] = route |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
441 environ['route.url_args'] = args |
94b36e721500
Another check in to back stuff up.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
442 return route.call(**args) |
0 | 443 |
444 def _mkdict(self, obj): | |
445 ret = {} | |
446 for name in dir(obj): | |
447 if name.startswith('_'): | |
448 continue | |
449 value = getattr(obj, name) | |
450 if not callable(value): | |
451 ret[name] = value | |
452 return ret |