forked from jan/debianmemberportfolio
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
# -*- python -*-
|
|
# -*- coding: utf-8 -*-
|
|
#
|
|
# DDPortfolio service TemplateController
|
|
# Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
|
#
|
|
# This file is part of DDPortfolio service.
|
|
#
|
|
# DDPortfolio service is free software: you can redistribute it and/or
|
|
# modify it under the terms of the GNU Affero General Public License
|
|
# as published by the Free Software Foundation, either version 3 of
|
|
# the License, or (at your option) any later version.
|
|
#
|
|
# DDPortfolio service is distributed in the hope that it will be
|
|
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public
|
|
# License along with this program. If not, see
|
|
# <http://www.gnu.org/licenses/>.
|
|
#
|
|
from ddportfolioservice.lib.base import BaseController
|
|
|
|
class TemplateController(BaseController):
|
|
|
|
def view(self, url):
|
|
"""By default, the final controller tried to fulfill the request
|
|
when no other routes match. It may be used to display a template
|
|
when all else fails, e.g.::
|
|
|
|
def view(self, url):
|
|
return render('/%s' % url)
|
|
|
|
Or if you're using Mako and want to explicitly send a 404 (Not
|
|
Found) response code when the requested template doesn't exist::
|
|
|
|
import mako.exceptions
|
|
|
|
def view(self, url):
|
|
try:
|
|
return render('/%s' % url)
|
|
except mako.exceptions.TopLevelLookupException:
|
|
abort(404)
|
|
|
|
By default this controller aborts the request with a 404 (Not
|
|
Found)
|
|
"""
|
|
abort(404)
|