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 <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2012-11-16 10:25:50 +01:00
parent 4487d51c81
commit b745bb50d8
2 changed files with 7 additions and 2 deletions

View File

@ -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]

View File

@ -15,11 +15,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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()"""