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.
  • [get | view] (2004-06-16 03:18:22, 2.1 KB) [[attachment:ViewTrackbacks.py]]
  • [get | view] (2004-06-19 23:54:48, 1.4 KB) [[attachment:blogpost.py]]
  • [get | view] (2004-06-28 00:47:23, 0.5 KB) [[attachment:footnotediff.txt]]
  • [get | view] (2004-06-19 23:45:08, 1.3 KB) [[attachment:form.py.diff]]
  • [get | view] (2004-06-28 00:47:09, 7.9 KB) [[attachment:formatInMemory.py]]
  • [get | view] (2004-06-16 03:18:15, 4.9 KB) [[attachment:trackback.py]]
 All files | Selected Files: delete move to page copy to page

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