Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / controllers / template.py @ 4d783824

History | View | Annotate | Download (1016 Bytes)

1
# -*- coding: utf-8 -*-
2
"""Fallback controller."""
3

    
4
from vigiboard.lib.base 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)