aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/response.py
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-28 00:14:50 +0200
committerElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-28 23:09:20 +0200
commit2e6ee596ad9dbc794979069f2f14b856db02343b (patch)
tree0b6559f86001b33053c1956701b280ed044e749b /mediagoblin/tools/response.py
parent8f88b1f6dc88f76b5e01bc43db26055ab3fbc921 (diff)
downloadmediagoblin-2e6ee596ad9dbc794979069f2f14b856db02343b.tar.lz
mediagoblin-2e6ee596ad9dbc794979069f2f14b856db02343b.tar.xz
mediagoblin-2e6ee596ad9dbc794979069f2f14b856db02343b.zip
Create redir_obj and use it around.
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.
Diffstat (limited to 'mediagoblin/tools/response.py')
-rw-r--r--mediagoblin/tools/response.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mediagoblin/tools/response.py b/mediagoblin/tools/response.py
index 80df1f5a..aaf31d0b 100644
--- a/mediagoblin/tools/response.py
+++ b/mediagoblin/tools/response.py
@@ -99,3 +99,10 @@ def redirect(request, *args, **kwargs):
if querystring:
location += querystring
return werkzeug.utils.redirect(location)
+
+
+def redirect_obj(request, obj):
+ """Redirect to the page for the given object.
+
+ Requires obj to have a .url_for_self method."""
+ return redirect(request, location=obj.url_for_self(request.urlgen))