Attachment 'blogpost.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - blogpost action
4
5 Take info submitted via form and create/append to a subpage.
6 The subpage will be formatted so it is like those created via the
7 MonthCalendar macro (allowing for the Include macro to be used in the same way)
8
9 @copyright: 2004 Jos Yule (jos@theorganization.net)
10 @license: GNU GPL, see COPYING for details.
11 """
12
13 # Imports
14 from MoinMoin.PageEditor import PageEditor
15 from MoinMoin.Page import Page
16 from MoinMoin import wikiutil
17 import time
18
19 def execute(pagename, request):
20 """ Test a user defined form.
21 """
22 _ = request.getText
23
24 year = time.localtime()[0]
25 month = time.localtime()[1]
26 day = time.localtime()[2]
27
28 newPage = "%s/%4d-%02d-%02d" % (request.form['addtopage'][0], year, month, day)
29
30 postPage = Page(newPage)
31
32 if not postPage.exists():
33 pageText = ''
34 else:
35 pageText = postPage.get_raw_body()
36
37 keyDict = {}
38
39 for key in request.form.keys():
40 keyDict[key.lower()] = request.form.get(key)
41
42 if keyDict['form_headline'] is not '':
43 pageText = "''' " + keyDict['form_headline'][0] + " '''\n\n" + keyDict['form_text'][0] + "\n\n" + pageText
44 else:
45 pageText = "\n" + keyDict['form_text'][0] + "\n\n" + pageText
46
47 savePage = PageEditor(newPage, request)
48 savePage._write_file(pageText)
49 postPage = Page(newPage)
50 postPage.send_page(request, msg='%s' % pageText)
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.