changeset 1611:435e0748d573

getAttachUrl gets an optional parameter for do='get' or do='view'
author ReimarBauer <R.Bauer@fz-juelich.de>
date Sun, 08 Oct 2006 21:16:15 +0200
parents 48194fc011e5
children c0f9f5f1f308
files MoinMoin/action/AttachFile.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Sun Oct 08 21:10:09 2006 +0200
+++ b/MoinMoin/action/AttachFile.py	Sun Oct 08 21:16:15 2006 +0200
@@ -82,7 +82,7 @@
     else:
         return u"/".join(pieces[:-1]), pieces[-1]
 
-def getAttachUrl(pagename, filename, request, addts=0, escaped=0):
+def getAttachUrl(pagename, filename, request, addts=0, escaped=0, do='get'):
     """ Get URL that points to attachment `filename` of page `pagename`.
 
         If 'addts' is true, a timestamp with the file's modification time
@@ -103,9 +103,12 @@
             wikiutil.url_quote(filename), timestamp)
     else:
         # send file via CGI
-        url = "%s/%s?action=%s&do=get&target=%s" % (
+        if do not in ['get', 'view']:
+            do = 'get'
+
+        url = "%s/%s?action=%s&do=%s&target=%s" % (
             request.getScriptname(), wikiutil.quoteWikinameURL(pagename),
-            action_name, wikiutil.url_quote_plus(filename))
+            action_name, do, wikiutil.url_quote_plus(filename))
     if escaped:
         url = wikiutil.escape(url)
     return url