Revision ff5d5494
Suppression du "TemplateController" dans vigiboard & vigigraph (créé par défaut par TG2 mais jamais utilisé).
Améliorations pylint dans VigiGraph + correction d'une typo dans le !RPCController.
Ajout de docstrings.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@2841 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/template.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
"""Fallback controller.""" |
|
3 |
|
|
4 |
from vigilo.turbogears.controllers import BaseController |
|
5 |
from tg import expose |
|
6 |
|
|
7 |
__all__ = ['TemplateController'] |
|
8 |
|
|
9 |
# pylint: disable-msg=R0201 |
|
10 |
class TemplateController(BaseController): |
|
11 |
""" |
|
12 |
The fallback controller for vigiboard. |
|
13 |
|
|
14 |
By default, the final controller tried to fulfill the request |
|
15 |
when no other routes match. It may be used to display a template |
|
16 |
when all else fails, e.g.:: |
|
17 |
|
|
18 |
def view(self, url): |
|
19 |
return render('/%s' % url) |
|
20 |
|
|
21 |
Or if you're using Mako and want to explicitly send a 404 (Not |
|
22 |
Found) response code when the requested template doesn't exist:: |
|
23 |
|
|
24 |
import mako.exceptions |
|
25 |
|
|
26 |
def view(self, url): |
|
27 |
try: |
|
28 |
return render('/%s' % url) |
|
29 |
except mako.exceptions.TopLevelLookupException: |
|
30 |
abort(404) |
|
31 |
|
|
32 |
""" |
|
33 |
|
|
34 |
@expose() |
|
35 |
def view(self, url): |
|
36 |
"""Abort the request with a 404 HTTP status code.""" |
|
37 |
abort(404) |
Also available in: Unified diff