Bring back the ascii art goblin! For python 2 anyway.

This does a "friendly" fallback where it skips the middleware on python 3.
This commit is contained in:
Christopher Allan Webber 2014-10-10 15:46:08 -05:00
parent 2b475821a1
commit 03969d8521
2 changed files with 7 additions and 4 deletions

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from paste.exceptions.errormiddleware import make_error_middleware
MGOBLIN_ERROR_MESSAGE = """\ MGOBLIN_ERROR_MESSAGE = """\
<div style="text-align:center;font-family: monospace"> <div style="text-align:center;font-family: monospace">
<h1>YEOWCH... that's an error!</h1> <h1>YEOWCH... that's an error!</h1>
@ -56,5 +54,11 @@ def mgoblin_error_middleware(app, global_conf, **kw):
It should take all of Paste's default options, so see: It should take all of Paste's default options, so see:
http://pythonpaste.org/modules/exceptions.html http://pythonpaste.org/modules/exceptions.html
""" """
# No paste? Fail in a friendly way!
try:
from paste.exceptions.errormiddleware import make_error_middleware
except ImportError:
return app
kw['error_message'] = MGOBLIN_ERROR_MESSAGE kw['error_message'] = MGOBLIN_ERROR_MESSAGE
return make_error_middleware(app, global_conf, **kw) return make_error_middleware(app, global_conf, **kw)

View File

@ -6,8 +6,7 @@
debug = false debug = false
[pipeline:main] [pipeline:main]
# pipeline = errors mediagoblin pipeline = errors mediagoblin
pipeline = mediagoblin
[app:mediagoblin] [app:mediagoblin]
use = egg:mediagoblin#app use = egg:mediagoblin#app