From: Sebastian Spaeth Date: Fri, 16 Nov 2012 09:25:50 +0000 (+0100) Subject: Remove webob from render_to_response X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b745bb50d8a4c92b5adbbd6918262ff8c9cc9609;p=mediagoblin.git Remove webob from render_to_response We were still using webob's Response objects for template rendering. Transition to werkzeug's Response object. One caveat was that it seemed to have used the default mimetype "text/plain" for all pages, so we override the default Response class, setting the default mime type to "text/html". Signed-off-by: Sebastian Spaeth --- diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 876ded4e..8bd2496f 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -193,7 +193,8 @@ class MediaGoblinApp(object): except NotFound as exc: return render_404(request)(environ, start_response) except HTTPException as exc: - # Support legacy webob.exc responses + # exceptions that match() is documented to return: + # MethodNotAllowed, RequestRedirect TODO: need to handle ??? return exc(environ, start_response) view_func = view_functions[endpoint] diff --git a/mediagoblin/tools/response.py b/mediagoblin/tools/response.py index ed23f0f7..b02dd6b5 100644 --- a/mediagoblin/tools/response.py +++ b/mediagoblin/tools/response.py @@ -15,11 +15,15 @@ # along with this program. If not, see . import werkzeug.utils -from webob import Response +from werkzeug.wrappers import Response as wz_Response from mediagoblin.tools.template import render_template from mediagoblin.tools.translate import (lazy_pass_to_ugettext as _, pass_to_ugettext) +class Response(wz_Response): + """Set default response mimetype to HTML, otherwise we get text/plain""" + default_mimetype = u'text/html' + def render_to_response(request, template, context, status=200): """Much like Django's shortcut.render()"""