Attachment 'NaturalAttachmentUrls.patch'

Download

   1 diff -Naur MoinMoin/wsgiapp.py MoinMoin-patched/wsgiapp.py
   2 --- MoinMoin/wsgiapp.py	2010-06-26 15:46:46.000000000 -0600
   3 +++ MoinMoin-patched/wsgiapp.py	2012-03-03 22:45:39.000000000 -0700
   4 @@ -182,6 +182,12 @@
   5      # Try action
   6      else:
   7          from MoinMoin import action
   8 +
   9 +        p, f = action.AttachFile.absoluteName(context.page.page_name, context.page.page_name)
  10 +        if action.AttachFile.exists(context, p, f, create=0):
  11 +            url = action.AttachFile.getAttachUrl(p, f, context)
  12 +            return context.http_redirect(url)
  13 +
  14          handler = action.getHandler(context, action_name)
  15          if handler is None:
  16              msg = _("You are not allowed to do %(action_name)s on this page.") % {
  17 diff -Naur MoinMoin/action/AttachFile.py MoinMoin-patched/action/AttachFile.py
  18 --- MoinMoin/action/AttachFile.py	2010-06-26 15:46:46.000000000 -0600
  19 +++ MoinMoin-patched/action/AttachFile.py	2012-03-03 22:45:39.000000000 -0700
  20 @@ -152,7 +152,7 @@
  21      return attach_link
  22  
  23  
  24 -def getFilename(request, pagename, filename):
  25 +def getFilename(request, pagename, filename, create=1):
  26      """ make complete pathfilename of file "name" attached to some page "pagename"
  27          @param request: request object
  28          @param pagename: name of page where the file is attached to (unicode)
  29 @@ -162,12 +162,12 @@
  30      """
  31      if isinstance(filename, unicode):
  32          filename = filename.encode(config.charset)
  33 -    return os.path.join(getAttachDir(request, pagename, create=1), filename)
  34 +    return os.path.join(getAttachDir(request, pagename, create), filename)
  35  
  36  
  37 -def exists(request, pagename, filename):
  38 +def exists(request, pagename, filename, create=1):
  39      """ check if page <pagename> has a file <filename> attached """
  40 -    fpath = getFilename(request, pagename, filename)
  41 +    fpath = getFilename(request, pagename, filename, create)
  42      return os.path.exists(fpath)
  43  
  44  

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-03-26 16:15:51, 1.9 KB) [[attachment:NaturalAttachmentUrls.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.