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.You are not allowed to attach a file to this page.