Mercurial > p > roundup > code
comparison roundup/cgi/engine_jinja2.py @ 6031:0a357d3b3557
Flake8 fixes: Raise NotImplementedError not NotImplemented; whitespace
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 03 Jan 2020 20:45:40 -0500 |
| parents | 91391a366d92 |
| children | 238dafbe521c |
comparison
equal
deleted
inserted
replaced
| 6030:ed8a9974c1bd | 6031:0a357d3b3557 |
|---|---|
| 40 # http://jinja.pocoo.org/docs/api/#loaders | 40 # http://jinja.pocoo.org/docs/api/#loaders |
| 41 | 41 |
| 42 from roundup.cgi.templating import context, LoaderBase, TemplateBase | 42 from roundup.cgi.templating import context, LoaderBase, TemplateBase |
| 43 from roundup.anypy.strings import s2u | 43 from roundup.anypy.strings import s2u |
| 44 | 44 |
| 45 | |
| 45 class Jinja2Loader(LoaderBase): | 46 class Jinja2Loader(LoaderBase): |
| 46 def __init__(self, dir): | 47 def __init__(self, dir): |
| 47 self._env = jinja2.Environment( | 48 self._env = jinja2.Environment( |
| 48 loader=jinja2.FileSystemLoader(dir), | 49 loader=jinja2.FileSystemLoader(dir), |
| 49 extensions=[] | 50 extensions=[] |
| 76 return pt | 77 return pt |
| 77 | 78 |
| 78 def precompile(self): | 79 def precompile(self): |
| 79 pass | 80 pass |
| 80 | 81 |
| 82 | |
| 81 class Jinja2ProxyPageTemplate(TemplateBase): | 83 class Jinja2ProxyPageTemplate(TemplateBase): |
| 82 def __init__(self, template): | 84 def __init__(self, template): |
| 83 self._tpl = template | 85 self._tpl = template |
| 84 | 86 |
| 85 def render(self, client, classname, request, **options): | 87 def render(self, client, classname, request, **options): |
| 86 # [ ] limit the information passed to the minimal necessary set | 88 # [ ] limit the information passed to the minimal necessary set |
| 87 c = context(client, self, classname, request) | 89 c = context(client, self, classname, request) |
| 88 c.update({'options': options}) | 90 c.update({'options': options}) |
| 89 s = self._tpl.render(c) | 91 s = self._tpl.render(c) |
| 90 return s if sys.version_info[0] > 2 else s.encode(client.STORAGE_CHARSET, ) | 92 return s if sys.version_info[0] > 2 else \ |
| 93 s.encode(client.STORAGE_CHARSET, ) | |
| 91 | 94 |
| 92 def __getitem__(self, name): | 95 def __getitem__(self, name): |
| 93 # [ ] figure out what are these for | 96 # [ ] figure out what are these for |
| 94 raise NotImplemented | 97 raise NotImplementedError |
| 95 #return self._pt[name] | 98 #return self._pt[name] |
| 96 | 99 |
| 97 def __getattr__(self, name): | 100 def __getattr__(self, name): |
| 98 # [ ] figure out what are these for | 101 # [ ] figure out what are these for |
| 99 raise NotImplemented | 102 raise NotImplementedError |
| 100 #return getattr(self._pt, name) | 103 #return getattr(self._pt, name) |
