annotate MoinMoin/action/Load.py @ 3234:a739558ca3dc

Page.url() default changed to relative=False
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 10 Mar 2008 00:21:21 +0100
parents ba14d391c2ba
children ca2d37e7c9d0
rev   line source
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
1771
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
3 MoinMoin - Action macro for page creation from file or attach file to current page
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1994
diff changeset
5 @copyright: 2007 MoinMoin:ReimarBauer
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
6 @license: GNU GPL, see COPYING for details.
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 """
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 import os
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 from MoinMoin import wikiutil, config
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 from MoinMoin.action import ActionBase, AttachFile
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 from MoinMoin.PageEditor import PageEditor
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 from MoinMoin.Page import Page
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 class Load(ActionBase):
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 """ Load page action
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 Note: the action name is the class name
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 """
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19 def __init__(self, pagename, request):
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 ActionBase.__init__(self, pagename, request)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 self.use_ticket = True
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 _ = self._
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 self.form_trigger = 'Load'
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 self.form_trigger_label = _('Load')
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 self.pagename = pagename
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 self.method = 'POST'
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 self.enctype = 'multipart/form-data'
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 def do_action(self):
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 """ Load """
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 status = False
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 _ = self._
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 form = self.form
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34 author = self.request.user.name
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36 rename = form.get('rename', [u''])[0]
1797
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
37
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38 filename = None
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
39 if 'file__filename__' in form:
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 filename = form['file__filename__']
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 filecontent = form['file'][0]
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 bytes = len(filecontent)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44
1771
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
45 overwrite = False
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
46 if 'overwrite' in form:
1771
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
47 overwrite = True
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 target = filename
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 if rename:
1922
f486526720c5 renamed wikiutil.clean_comment > clean_input, moved translation map to config
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
51 target = wikiutil.clean_input(rename.strip())
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 # preprocess the filename
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 # strip leading drive and path (IE misbehaviour)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 if len(target) > 1 and (target[1] == ':' or target[0] == '\\'): # C:.... or \path... or \\server\...
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 bsindex = target.rfind('\\')
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 if bsindex >= 0:
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
58 target = target[bsindex+1:]
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
60 if 'attachment' in self.request.form and self.request.user.may.write(self.pagename):
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 attach_dir = AttachFile.getAttachDir(self.request, self.pagename, create=1)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 fpath = os.path.join(attach_dir, target).encode(config.charset)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63 exists = os.path.exists(fpath)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 if exists and not overwrite:
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 msg = _("Attachment '%(target)s' (remote name '%(filename)s') already exists.") % {
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 'target': target, 'filename': filename}
1771
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
67 return status, msg
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
68
1991
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
69 if exists and overwrite:
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
70 if self.request.user.may.delete(self.pagename):
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
71 try:
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
72 os.remove(fpath)
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
73 except:
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
74 pass
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
75 else:
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
76 msg = _("You are not allowed to delete attachments on this page.")
a51db06be0bd Load: only exists and overwrite need to test for delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1922
diff changeset
77 return status, msg
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 AttachFile.add_attachment(self.request, self.pagename, target, filecontent)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 bytes = len(filecontent)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
81 msg = _("Attachment '%(target)s' (remote name '%(filename)s') with %(bytes)d bytes saved.") % {
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82 'target': target, 'filename': filename, 'bytes': bytes}
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83 status = True
1771
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
84
1797
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
85 else:
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
86 filecontent = unicode(filecontent, config.charset)
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
87 self.pagename = wikiutil.escape(target)
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
88 page = Page(self.request, self.pagename)
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
89 pagedir = page.getPagePath("", check_create=0)
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
90 rev = Page.get_current_from_pagedir(page, pagedir)
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
91 pg = PageEditor(self.request, self.pagename, do_editor_backup=0, uid_override=author)
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 try:
1797
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
93 msg = pg.saveText(filecontent, rev)
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 status = True
1797
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
95 except pg.EditConflict, e:
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
96 msg = e.message
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
97 except pg.SaveError, msg:
25c93ded258b AttachFile: getText of add_attachment fixed, Load:only PageEditor restricts uploading of pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1771
diff changeset
98 msg = unicode(msg)
1771
d3bb97cd7b35 decoding to config.charset added and user will be requested to select attachment for files which can't be decoded
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1750
diff changeset
99
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 return status, msg
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 def do_action_finish(self, success):
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 if success:
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2966
diff changeset
104 url = Page(self.request, self.pagename).url(self.request)
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 self.request.http_redirect(url)
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 self.request.finish()
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 else:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2286
diff changeset
108 self.render_msg(self.make_form(), "dialog")
1750
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110 def get_form_html(self, buttons_html):
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
111 _ = self._
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
112 return """
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
113 %(querytext_pages)s
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114 <dl>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
115 <dt>%(upload_label_file)s</dt>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
116 <dd><input type="file" name="file" size="50" value=""></dd>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 <dt>%(upload_label_rename)s</dt>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
118 <dd><input type="text" name="rename" size="50" value=""></dd>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 %(querytext_attachment)s
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 <dt>%(upload)s <input type="checkbox" name="attachment" value="off">
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
121 %(overwrite)s <input type="checkbox" name="overwrite" value="off"></dt>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
122 </dl>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
123 <p>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124 <input type="hidden" name="action" value="%(action_name)s">
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 <input type="hidden" name="do" value="upload">
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 </p>
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
127 <td class="buttons">
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
128 %(buttons_html)s
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
129 </td>""" % {
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 'querytext_pages': '<h2>' + _("New Page or New Attachment") + '</h2><p>' +
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 _("""You can upload a file to a new page or choose to upload a file as attachment for the current page""") + '</p>',
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 'querytext_attachment': '<h2>' + _("New Attachment") + '</h2><p>' +
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
133 _("""An upload will never overwrite an existing file. If there is a name
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
134 conflict, you have to rename the file that you want to upload.
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
135 Otherwise, if "Rename to" is left blank, the original filename will be used.""") + '</p>',
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
136 'buttons_html': buttons_html,
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
137 'upload': _('attachment'),
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
138 'overwrite': _('overwrite'),
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
139 'action_name': self.form_trigger,
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
140 'upload_label_file': _('Upload'),
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
141 'upload_label_rename': _('New Name'),
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
142 }
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
143
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
144 def execute(pagename, request):
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
145 """ Glue code for actions """
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
146 Load(pagename, request).render()
88fa1ffd2574 action macro: Load for uploading and page creation and Save for downloading a page added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
147