X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/5fa3452111e4f29afacdec939b31ae7bfe1c5049..efdbb22873232827398ba7605f8b35c605c043e9:/floof/lib/helpers.py?ds=sidebyside diff --git a/floof/lib/helpers.py b/floof/lib/helpers.py index 28e9176..b4cac1f 100644 --- a/floof/lib/helpers.py +++ b/floof/lib/helpers.py @@ -8,6 +8,7 @@ available to Controllers. This module is available to both as 'h'. # from webhelpers.html.tags import checkbox, password from webhelpers import * from routes import url_for, redirect_to +from pylons import url # Scaffolding helper imports from webhelpers.html.tags import * @@ -30,3 +31,13 @@ def get_object_or_404(model, **kw): abort(404) return obj +def get_comment_owner_url(**route): + """Given a view route, returns the owner_url route parameter for generating + comment URLs. + """ + if 'owner_url' in route: + # We're already in a comments page. Reuse the existing owner URL + return route['owner_url'] + + # url() returns URLs beginning with a slash. We just need to strip it. + return url(**route)[1:]