Attachment 'SubscribeUser.py'
Download 1 """
2 MoinMoin - Subscribeuser - Action
3 Subscribe an user to a page
4
5 Author: Daniela Nicklas <nicklas@informatik.uni-stuttgart.de>
6 (c) 2003, all rights reserved
7
8 Designed for MoinMoin 1.1
9
10 """
11
12 import string
13
14 from MoinMoin import wikiutil, webapi, config
15 from MoinMoin.formatter.text_html import Formatter
16
17 from MoinMoin.Page import Page
18 from MoinMoin.i18n import _
19 from MoinMoin.macro import autosub
20
21 def show_form(pagename, request):
22 _ = request.getText
23 webapi.http_headers(request)
24 wikiutil.send_title(request, _("Subscribe User to %s"%pagename))
25
26 request.write(
27 """
28 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
29 <input type="hidden" name="action" value="SubscribeUser">
30 Enter Username: <input type="text" name="users" size="50">
31 <input type="submit" value="Subscribe">
32 </form>
33 """ % {
34 'baseurl': webapi.getBaseURL(),
35 'pagename': wikiutil.quoteWikiname(pagename),
36 })
37 wikiutil.send_footer(request, pagename, showpage=1)
38
39 def show_result(pagename, request):
40 _ = request.getText
41 webapi.http_headers(request)
42 # send title
43 p = Page(pagename)
44 wikiutil.send_title(request, _("Subscribed for %s:"%pagename))
45 # parse userlist and call macro
46 username = []
47 username.append(request.form['users'].value)
48 result = autosub.subscribe_users(request, username, pagename)
49 # print result
50 request.write(result)
51 wikiutil.send_footer(request, pagename, showpage=1)
52
53 def show_error(pagename, request):
54 _ = request.getText
55 p = Page(pagename)
56 msg = _('''
57 <b>This wiki is not enabled for mail processing.<br>
58 Contact the owner of the wiki, who can either enable email,
59 or do not use the SubscribeUser action.</b>
60 ''')
61 p.send_page(request, msg)
62
63 def execute(pagename, request):
64 _ = request.getText
65 # check config
66 if not config.mail_smarthost:
67 show_error(pagename, request)
68 elif not request.form.has_key('users'):
69 show_form(pagename, request)
70 else:
71 show_result(pagename,request)
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.