2009-01-21 16:11:39 +01:00
|
|
|
# -*- python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# DDPortfolio service TemplateController
|
2012-01-07 01:46:57 +01:00
|
|
|
# Copyright © 2009, 2010, 2011, 2012 Jan Dittberner <jan@dittberner.info>
|
2009-01-21 16:11:39 +01:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
2010-04-17 12:48:31 +02:00
|
|
|
from ddportfolioservice.lib.base import BaseController
|
2009-01-20 22:39:05 +01:00
|
|
|
|
2012-01-07 01:46:57 +01:00
|
|
|
|
2009-01-20 22:39:05 +01:00
|
|
|
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)
|