Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style |
| 3 | # license that can be found in the LICENSE file or at |
| 4 | # https://developers.google.com/open-source/licenses/bsd |
| 5 | |
| 6 | """Page class for generating somewhat informative project-page 404s. |
| 7 | |
| 8 | This page class produces a mostly-empty project subpage, which helps |
| 9 | users find what they're looking for by providing navigational menus, |
| 10 | rather than telling them "404. That's an error. That's all we know." |
| 11 | which is maddeningly not helpful when we already have a project pb |
| 12 | loaded. |
| 13 | """ |
| 14 | from __future__ import print_function |
| 15 | from __future__ import division |
| 16 | from __future__ import absolute_import |
| 17 | |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 18 | from six.moves import http_client |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 19 | from framework import exceptions |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 20 | from framework import flaskservlet |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 21 | from framework import servlet |
| 22 | |
| 23 | |
| 24 | class ErrorPage(servlet.Servlet): |
| 25 | """Page class for generating somewhat informative project-page 404s. |
| 26 | |
| 27 | This page class produces a mostly-empty project subpage, which helps |
| 28 | users find what they're looking for by providing navigational menus, |
| 29 | rather than telling them "404. That's an error. That's all we know." |
| 30 | which is maddeningly not helpful when we already have a project pb |
| 31 | loaded. |
| 32 | """ |
| 33 | |
| 34 | _PAGE_TEMPLATE = 'sitewide/project-404-page.ezt' |
| 35 | |
| 36 | def GatherPageData(self, mr): |
| 37 | """Build up a dictionary of data values to use when rendering the page.""" |
| 38 | if not mr.project_name: |
| 39 | raise exceptions.InputException('No project specified') |
| 40 | return { |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 41 | 'http_response_code': http_client.NOT_FOUND, |
| 42 | } |
| 43 | |
| 44 | # def Get404Page(self, **kwargs): |
| 45 | # return self.handler(**kwargs) |