aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/response.py
Commit message (Collapse)AuthorAgeFilesLines
* Create redir_obj and use it around.Elrond2013-04-281-0/+7
| | | | | | | | This is a shortcut function to redirect to the main page for an object. Objects currently supported: media entries and collections. And go around and replace various places to use this.
* Provide tools.response.render_http_exception and use thatSebastian Spaeth2012-12-231-0/+19
| | | | | | | | | | | | | | | | | | | | | | | After the webob->werkzeug transition, controller functions can raise werkzeug.HttpExceptions. We need to catch these in app.py when calling the controller and handle them, rendering the corresponding error Response() object. For consistency, we also want to allow meddleware functions to raise HttpExceptions (e.g. the csrf meddleware needs to complain about lack of cookies), so wrap the request and response parts of the meddleware too. Finally, the urlmap.match() can also raise HttpExceptions, so we give it the same treatment (render_http_exception). I am not sure, if we do not need to handle the Redirect exception there in any different way though... The new function render_http_exception makes use of the render_error infrastructure to return a nicely templated error page. It also checks if the stock error messages was used in cases where we have localizations (403, 404) and use those. It is now possible to do things like "raise Forbidden(_('You suckr'))" or raise NotFound(_('where is my left show again')) if you want to return customized error messages to the user. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove webob from render_to_responseSebastian Spaeth2012-12-211-1/+5
| | | | | | | | | | 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>
* Extend redirect helper to take optional location keywordSebastian Spaeth2012-12-211-10/+17
| | | | | | | | | | | | | In order to move away from webob with its redirect(location=...) we need to provide a redirect function that allows to directly specify the URL rather than the urlgen parameters that we now use. Extend our MG.tools:redirect helper so we can pass in the direct URL via the optional "location" keyword. This commit does not switch over any redirect consumers yet. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Switching both gettext calls to _() so babel can find/extract them.Christopher Allan Webber2012-12-141-4/+6
| | | | Babel looks for _() and gettext() so this is necessary.
* Use the correct translation mechanismSebastian Spaeth2012-12-141-3/+4
| | | | | | | We accidentally used the fake translation mechanism here which will not actually translate anything. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fix error page textSebastian Spaeth2012-11-291-2/+2
| | | | | | | Thanks to Elrond for noticing. We wrap error messages in <p> tags, so there is no need to start the error message with <p>. DOH Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Implement generic error pagesSebastian Spaeth2012-11-291-5/+26
| | | | | | | | | | | Rather than having a 404.html, a 403.html, a 500.html,... we have a generic error.html template that we pass in an error code, a title and a (html'ish) error message. Implement the common render_404 and render_403 shortcuts. More exotic cases can be achieved by the generic render_error function. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* It's 2012 all up in hereChristopher Allan Webber2012-02-021-1/+1
|
* Should be 404 for 404s, not 400 :)Christopher Allan Webber2011-12-011-1/+1
|
* Merge remote-tracking branch 'remotes/nyergler/pep8-ification'Christopher Allan Webber2011-11-131-1/+4
| | | | | | | | Conflicts: mediagoblin/db/migrations.py mediagoblin/db/models.py mediagoblin/user_pages/views.py mediagoblin/util.py
* Finished splitting util.py into separate files.Aaron Williamson2011-10-011-0/+44