Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # coding=utf-8 |
||
2 | from tracim.views.controllers import Controller |
||
3 | from pyramid.config import Configurator |
||
4 | from pyramid.response import Response |
||
5 | from pyramid.exceptions import NotFound |
||
6 | |||
7 | |||
8 | class DefaultController(Controller): |
||
9 | |||
10 | @classmethod |
||
11 | def notfound_view(cls, request): |
||
12 | request.response.status = 404 |
||
13 | return {} |
||
14 | |||
15 | @classmethod |
||
16 | def test_config(cls, request): |
||
17 | try: |
||
18 | app_config = request.registry.settings['CFG'] |
||
19 | project = app_config.WEBSITE_TITLE |
||
20 | except Exception as e: |
||
21 | return Response(e, content_type='text/plain', status=500) |
||
22 | return {'project': project} |
||
23 | |||
24 | def bind(self, configurator: Configurator): |
||
25 | configurator.add_static_view('static', 'static', cache_max_age=3600) |
||
26 | configurator.add_view( |
||
27 | self.notfound_view, |
||
28 | renderer='tracim:templates/404.jinja2', |
||
29 | context=NotFound, |
||
30 | ) |
||
31 | |||
32 | configurator.add_route('test_config', '/') |
||
33 | configurator.add_view( |
||
34 | self.test_config, |
||
35 | route_name='test_config', |
||
36 | renderer='tracim:templates/mytemplate.jinja2', |
||
37 | ) |
||
38 |