Attachment 'log-1.7.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 log - add log entry
4 @license: GNU GPL, see COPYING for details.
5 @copyright: 2007 MoinMoin:ReimarBauer
6 """
7 from MoinMoin import wikiutil
8 from MoinMoin.PageEditor import PageEditor
9 from MoinMoin.Page import Page
10
11 def execute(pagename, request):
12 _ = request.getText
13 ticket = 'Geheim!'
14 esc = wikiutil.escape
15 date = esc(request.form.get('date', ['None'])[0])
16 comment = esc(request.form.get('comment', ['None'])[0])
17 secret = esc(request.form.get('ticket', ['wrong'])[0])
18
19 if (ticket != secret or date == 'None' or
20 comment == 'None'):
21 msg = _(u"A severe error occured:")
22 request.theme.add_msg(msg, "error")
23 Page(request, pagename).send_page()
24 return
25
26 pagename = u'LogPage'
27 page = Page(request, pagename)
28 raw = u''
29
30 if page.exists():
31 raw = page.get_raw_body()
32
33 result = "|| %s || %s ||" % (date, comment)
34 newtext = "%s%s\n" % (raw, result)
35 try:
36 PageEditor(request, pagename).saveText(newtext, 0)
37 msg = u"OK!"
38 request.theme.add_msg(msg, "info")
39 Page(request, pagename).send_page()
40 except:
41 msg = _(u"A severe error occured:")
42 request.theme.add_msg(msg, "error")
43 Page(request, pagename).send_page()
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.