Commit session after alembic updates have finished
[mediagoblin.git] / mediagoblin / errormiddleware.py
CommitLineData
72ae87af 1# GNU MediaGoblin -- federated, autonomous media hosting
cf29e8a8 2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
72ae87af
CAW
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Affero General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
72ae87af
CAW
17MGOBLIN_ERROR_MESSAGE = """\
18<div style="text-align:center;font-family: monospace">
19 <h1>YEOWCH... that's an error!</h1>
20 <pre>
21.-------------------------.
22| __ _ |
23| -, \_,------,_// |
24| <\ ,-- --.\ |
9ac73717 25| / (x ) ( X ) |
72ae87af
CAW
26| ' '--, ,--'\ |
27| / \ -v-v-u-v / |
28| . '.__.--__'.\ |
29| / ',___/ / \__/' |
30| | | ,'\_'/, || |
31| \_| | | | | || |
32| W',_ ||| |||_'' |
33| | '------'| |
34| |__| |_|_ |
35| ,,,-' '-,,, |
36'-------------------------'
37 </pre>
38 <p>Something bad happened, and things broke.</p>
39 <p>If this is not your website, you may want to alert the owner.</p>
40 <br><br>
41 <p>
42 Powered... er broken... by
43 <a href="http://www.mediagoblin.org">MediaGoblin</a>,
44 a <a href="http://www.gnu.org">GNU Project</a>.
45 </p>
46</div>"""
47
48
49def mgoblin_error_middleware(app, global_conf, **kw):
ae72c638
CAW
50 """
51 MediaGoblin wrapped error middleware.
52
53 This is really just wrapping the error middleware from Paste.
54 It should take all of Paste's default options, so see:
55 http://pythonpaste.org/modules/exceptions.html
56 """
03969d85
CAW
57 # No paste? Fail in a friendly way!
58 try:
59 from paste.exceptions.errormiddleware import make_error_middleware
60 except ImportError:
61 return app
62
72ae87af
CAW
63 kw['error_message'] = MGOBLIN_ERROR_MESSAGE
64 return make_error_middleware(app, global_conf, **kw)