comparison MoinMoin/PageGraphicalEditor.py @ 4237:162002d5b148

Replaced some references to request.form with MultiDict-compatible semantics
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sun, 20 Jul 2008 18:49:20 +0200
parents a6c315ff8d66
children 07862b0663fd
comparison
equal deleted inserted replaced
4236:97bffc03c15f 4237:162002d5b148
87 return 87 return
88 88
89 # check if we want to load a draft 89 # check if we want to load a draft
90 use_draft = None 90 use_draft = None
91 if 'button_load_draft' in form: 91 if 'button_load_draft' in form:
92 wanted_draft_timestamp = int(form.get('draft_ts', ['0'])[0]) 92 wanted_draft_timestamp = int(form.get('draft_ts', '0'))
93 if wanted_draft_timestamp: 93 if wanted_draft_timestamp:
94 draft = self._load_draft() 94 draft = self._load_draft()
95 if draft is not None: 95 if draft is not None:
96 draft_timestamp, draft_rev, draft_text = draft 96 draft_timestamp, draft_rev, draft_text = draft
97 if draft_timestamp == wanted_draft_timestamp: 97 if draft_timestamp == wanted_draft_timestamp:
99 99
100 # Check for draft / normal / preview submit 100 # Check for draft / normal / preview submit
101 if use_draft is not None: 101 if use_draft is not None:
102 title = _('Draft of "%(pagename)s"') 102 title = _('Draft of "%(pagename)s"')
103 # Propagate original revision 103 # Propagate original revision
104 rev = int(form['draft_rev'][0]) 104 rev = int(form['draft_rev'])
105 self.set_raw_body(use_draft, modified=1) 105 self.set_raw_body(use_draft, modified=1)
106 preview = use_draft 106 preview = use_draft
107 elif preview is None: 107 elif preview is None:
108 title = _('Edit "%(pagename)s"') 108 title = _('Edit "%(pagename)s"')
109 else: 109 else:
119 lock_mins = _("Your edit lock on %(lock_page)s will expire in # minutes.") % {'lock_page': lock_page} 119 lock_mins = _("Your edit lock on %(lock_page)s will expire in # minutes.") % {'lock_page': lock_page}
120 lock_secs = _("Your edit lock on %(lock_page)s will expire in # seconds.") % {'lock_page': lock_page} 120 lock_secs = _("Your edit lock on %(lock_page)s will expire in # seconds.") % {'lock_page': lock_page}
121 121
122 # get request parameters 122 # get request parameters
123 try: 123 try:
124 text_rows = int(form['rows'][0]) 124 text_rows = int(form['rows'])
125 except StandardError: 125 except StandardError:
126 text_rows = self.cfg.edit_rows 126 text_rows = self.cfg.edit_rows
127 if request.user.valid: 127 if request.user.valid:
128 text_rows = int(request.user.edit_rows) 128 text_rows = int(request.user.edit_rows)
129 129
165 # If the page exists, we get the text from the page. 165 # If the page exists, we get the text from the page.
166 # TODO: maybe warn if template argument was ignored because the page exists? 166 # TODO: maybe warn if template argument was ignored because the page exists?
167 raw_body = self.get_raw_body() 167 raw_body = self.get_raw_body()
168 elif 'template' in form: 168 elif 'template' in form:
169 # If the page does not exist, we try to get the content from the template parameter. 169 # If the page does not exist, we try to get the content from the template parameter.
170 template_page = wikiutil.unquoteWikiname(form['template'][0]) 170 template_page = wikiutil.unquoteWikiname(form['template'])
171 if request.user.may.read(template_page): 171 if request.user.may.read(template_page):
172 raw_body = Page(request, template_page).get_raw_body() 172 raw_body = Page(request, template_page).get_raw_body()
173 if raw_body: 173 if raw_body:
174 request.write(_("[Content of new page loaded from %s]") % (template_page, ), '<br>') 174 request.write(_("[Content of new page loaded from %s]") % (template_page, ), '<br>')
175 else: 175 else:
241 241
242 # Create and send a ticket, so we can check the POST 242 # Create and send a ticket, so we can check the POST
243 request.write('<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(request)) 243 request.write('<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(request))
244 244
245 # Save backto in a hidden input 245 # Save backto in a hidden input
246 backto = form.get('backto', [None])[0] 246 backto = form.get('backto')
247 if backto: 247 if backto:
248 request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto))) 248 request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto)))
249 249
250 # button bar 250 # button bar
251 button_spellcheck = '<input class="button" type="submit" name="button_spellcheck" value="%s">' % _('Check Spelling') 251 button_spellcheck = '<input class="button" type="submit" name="button_spellcheck" value="%s">' % _('Check Spelling')
292 </script> 292 </script>
293 &nbsp; 293 &nbsp;
294 <input type="checkbox" name="trivial" id="chktrivialtop" value="1" %(checked)s onclick="toggle_trivial(this)"> 294 <input type="checkbox" name="trivial" id="chktrivialtop" value="1" %(checked)s onclick="toggle_trivial(this)">
295 <label for="chktrivialtop">%(label)s</label> 295 <label for="chktrivialtop">%(label)s</label>
296 ''' % { 296 ''' % {
297 'checked': ('', 'checked')[form.get('trivial', ['0'])[0] == '1'], 297 'checked': ('', 'checked')[form.get('trivial', '0') == '1'],
298 'label': _("Trivial change"), 298 'label': _("Trivial change"),
299 }) 299 })
300 300
301 from MoinMoin.security.textcha import TextCha 301 from MoinMoin.security.textcha import TextCha
302 request.write(TextCha(request).render()) 302 request.write(TextCha(request).render())
371 if self.cfg.mail_enabled: 371 if self.cfg.mail_enabled:
372 request.write(''' 372 request.write('''
373 &nbsp; 373 &nbsp;
374 <input type="checkbox" name="trivial" id="chktrivial" value="1" %(checked)s onclick="toggle_trivial(this)"> 374 <input type="checkbox" name="trivial" id="chktrivial" value="1" %(checked)s onclick="toggle_trivial(this)">
375 <label for="chktrivial">%(label)s</label> ''' % { 375 <label for="chktrivial">%(label)s</label> ''' % {
376 'checked': ('', 'checked')[form.get('trivial', ['0'])[0] == '1'], 376 'checked': ('', 'checked')[form.get('trivial', '0') == '1'],
377 'label': _("Trivial change"), 377 'label': _("Trivial change"),
378 }) 378 })
379 379
380 request.write(''' 380 request.write('''
381 &nbsp; 381 &nbsp;
382 <input type="checkbox" name="rstrip" id="chkrstrip" value="1" %(checked)s> 382 <input type="checkbox" name="rstrip" id="chkrstrip" value="1" %(checked)s>
383 <label for="chkrstrip">%(label)s</label> 383 <label for="chkrstrip">%(label)s</label>
384 </p> ''' % { 384 </p> ''' % {
385 'checked': ('', 'checked')[form.get('rstrip', ['0'])[0] == '1'], 385 'checked': ('', 'checked')[form.get('rstrip', '0') == '1'],
386 'label': _('Remove trailing whitespace from each line') 386 'label': _('Remove trailing whitespace from each line')
387 }) 387 })
388 388
389 request.write("</p>") 389 request.write("</p>")
390 390