Attachment 'getmmap.py'
Download
Toggle line numbers
1 "ExternalEdit Moinmoin action module"
2
3 # imports
4 import re
5 from MoinMoin.Page import Page
6
7
8
9 class MMapHandler:
10 def __init__(self, pagename):
11 self.pagename = pagename
12 # end def
13
14 def handle_request(self, request):
15 self.request = request
16 # use Page to get raw text
17 self.page = Page(request, self.pagename)
18 self.emit_mmap()
19
20 def emit_mmap(self):
21 headers = ['Content-Type: text/html',
22 'Pragma: no-cache']
23
24 ## use regex to find first <map>...</map> section in {{{#!freemind parser section }}}
25 body = self.page.get_raw_body()
26
27 p = re.compile('\{\{\{\s*#!freemind\s*(<map.*</map>)\s*\}\}\}', re.DOTALL)
28 s = p.search (body)
29
30 if (s == None):
31 mapText = "<map>" "</map>\n"
32 else :
33 mapText = s.group(1) + "\n"
34
35 headers.append('Content-Length: %s' % len(mapText))
36
37 ## send headers and map
38 self.request.http_headers(headers)
39 self.request.write(mapText)
40 self.request.no_closing_html_code = True
41
42
43 def execute(pagename, request):
44 handler = MMapHandler(pagename)
45 handler.handle_request(request)
46
47
48 # end def
49
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.