Attachment 'exportfile-1.6.0-1.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - exportfile Action macro
   4 
   5     PURPOSE::
   6         This action macro is used from text_x_exportfile to export to a plain/text file 
   7 
   8     CALLING SEQUENCE::
   9         called by text_x_exportfile POST Method
  10 
  11     MODIFICATION HISTORY::
  12         Version 1.6.0-1
  13         @copyright: 2007 by Reimar Bauer (R.Bauer@fz-juelich.de)
  14         @license: GNU GPL, see COPYING for details.
  15 """
  16 import os
  17 from MoinMoin import wikiutil
  18 from MoinMoin.action import AttachFile
  19 from MoinMoin.util import timefuncs
  20 
  21 def execute(pagename, request):
  22     ticket = request.form.get('ticket', [''])[0]
  23     if wikiutil.checkTicket(request, ticket):
  24 
  25         attachment_path = AttachFile.getAttachDir(request, pagename)
  26         timestamp = timefuncs.formathttpdate(int(os.path.getmtime(attachment_path)))
  27         file = request.form.get('file', [''])[0]
  28         raw = request.form.get('raw', [''])[0]
  29         content_type = request.form.get('content-type', [''])[0]
  30 
  31         if content_type == 'text/plain':
  32             request.emit_http_headers([
  33                 'Content-Type:  %s' % content_type,
  34                 'Last-Modified: %s' % timestamp,
  35                 'Content-Length: %d' % len(raw),
  36                 'Content-Disposition: %s; filename="%s"' % ('attachment', file),
  37             ])
  38             request.write(raw)
  39             return ()
  40         else:
  41             return ()
  42     else:
  43         return ()

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] (2007-01-02 19:13:36, 13.2 KB) [[attachment:ExportFile_1.png]]
  • [get | view] (2007-01-02 19:27:33, 0.2 KB) [[attachment:example.py]]
  • [get | view] (2007-01-02 19:27:41, 0.0 KB) [[attachment:example.txt]]
  • [get | view] (2007-01-02 19:14:06, 1.4 KB) [[attachment:exportfile-1.6.0-1.py]]
  • [get | view] (2007-01-02 19:27:52, 0.0 KB) [[attachment:exportfile.txt]]
  • [get | view] (2007-01-02 19:13:52, 4.4 KB) [[attachment:text_x_exportfile-1.6.0-1.py]]
  • [get | view] (2007-01-04 04:56:37, 4.0 KB) [[attachment:text_x_exportfile-1.6.0-2.py]]
  • [get | view] (2007-01-04 05:16:14, 3.6 KB) [[attachment:text_x_exportfile-1.6.0-3.py]]
  • [get | view] (2007-01-04 04:57:15, 1.1 KB) [[attachment:wikiutil_20070103_patch.txt]]
  • [get | view] (2007-01-04 05:15:49, 1.6 KB) [[attachment:wikiutil_20070104_patch.txt]]
 All files | Selected Files: delete move to page copy to page

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