Mercurial > moin > 1.9
changeset 4424:5ad5753ae311
pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
line wrap: on
line diff
--- a/MoinMoin/Page.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/Page.py Sun Nov 16 22:20:21 2008 +0100 @@ -1008,11 +1008,11 @@ send_special = keywords.get('send_special', False) print_mode = keywords.get('print_mode', 0) if print_mode: - media = request.form.get('media', 'print') + media = request.values.get('media', 'print') else: media = 'screen' self.hilite_re = (keywords.get('hilite_re') or - request.form.get('highlight', [None])[0]) + request.values.get('highlight')) # count hit? if keywords.get('count_hit', 0): @@ -1023,7 +1023,7 @@ pi = self.pi if 'redirect' in pi and not ( - 'action' in request.form or 'redirect' in request.form or content_only): + 'action' in request.values or 'redirect' in request.values or content_only): # redirect to another page # note that by including "action=show", we prevent endless looping # (see code in "request") or any cascaded redirection @@ -1048,8 +1048,8 @@ try: self.formatter.set_highlight_re(self.hilite_re) except re.error, err: - if 'highlight' in request.form: - del request.form['highlight'] + if 'highlight' in request.values: + del request.values['highlight'] request.theme.add_msg(_('Invalid highlighting regular expression "%(regex)s": %(error)s') % { 'regex': self.hilite_re, 'error': str(err), @@ -1113,8 +1113,8 @@ # This redirect message is very annoying. # Less annoying now without the warning sign. - if 'redirect' in request.form: - redir = request.form['redirect'] + if 'redirect' in request.values: + redir = request.values['redirect'] request.theme.add_msg('<strong>%s</strong><br>' % ( _('Redirected from page "%(page)s"') % {'page': wikiutil.link_tag(request, wikiutil.quoteWikinameURL(redir) + "?action=show", self.formatter.text(redir))}), "info")
--- a/MoinMoin/PageEditor.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/PageEditor.py Sun Nov 16 22:20:21 2008 +0100 @@ -275,9 +275,9 @@ # If the page exists, we get the text from the page. # TODO: maybe warn if template argument was ignored because the page exists? raw_body = self.get_raw_body() - elif 'template' in form: + elif 'template' in request.values: # If the page does not exist, we try to get the content from the template parameter. - template_page = wikiutil.unquoteWikiname(form['template']) + template_page = wikiutil.unquoteWikiname(request.values['template']) if request.user.may.read(template_page): raw_body = Page(request, template_page).get_raw_body() if raw_body: @@ -349,7 +349,7 @@ request.write('<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(request)) # Save backto in a hidden input - backto = form.get('backto') + backto = request.values.get('backto') if backto: request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto))) @@ -512,7 +512,7 @@ self._save_draft(newtext, rev) # shall we really save a draft on CANCEL? self.lock.release() - backto = request.form.get('backto') + backto = request.values.get('backto') if backto: pg = Page(request, backto) request.http_redirect(pg.url(request, relative=False)) @@ -670,7 +670,7 @@ # Remove cache entry (if exists) pg = Page(self.request, self.page_name) - key = self.request.form.get('key', 'text_html') + key = self.request.form.get('key', 'text_html') # XXX see cleanup code in deletePage caching.CacheEntry(self.request, pg, key, scope='item').remove() caching.CacheEntry(self.request, pg, "pagelinks", scope='item').remove()
--- a/MoinMoin/PageGraphicalEditor.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/PageGraphicalEditor.py Sun Nov 16 22:20:21 2008 +0100 @@ -165,9 +165,9 @@ # If the page exists, we get the text from the page. # TODO: maybe warn if template argument was ignored because the page exists? raw_body = self.get_raw_body() - elif 'template' in form: + elif 'template' in request.values: # If the page does not exist, we try to get the content from the template parameter. - template_page = wikiutil.unquoteWikiname(form['template']) + template_page = wikiutil.unquoteWikiname(request.values['template']) if request.user.may.read(template_page): raw_body = Page(request, template_page).get_raw_body() if raw_body: @@ -243,7 +243,7 @@ request.write('<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(request)) # Save backto in a hidden input - backto = form.get('backto') + backto = request.values.get('backto') if backto: request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto)))
--- a/MoinMoin/action/__init__.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/__init__.py Sun Nov 16 22:20:21 2008 +0100 @@ -237,7 +237,7 @@ Page(request, pagename, rev=rev).send_raw() def do_show(pagename, request, content_only=0, count_hit=1, cacheable=1, print_mode=0): - """ show a page, either current revision or the revision given by rev form value. + """ show a page, either current revision or the revision given by "rev=" value. if count_hit is non-zero, we count the request for statistics. """ # We must check if the current page has different ACLs. @@ -255,14 +255,14 @@ ) def do_format(pagename, request): - """ send a page using a specific formatter given by mimetype form key. + """ send a page using a specific formatter given by "mimetype=" value. Since 5.5.2006 this functionality is also done by do_show, but do_format has a default of text/plain when no format is given. It also does not count in statistics and also does not set the cacheable flag. DEPRECATED: remove this action when we don't need it any more for compatibility. """ - if 'mimetype' not in request.form: - request.form['mimetype'] = u"text/plain" + if 'mimetype' not in request.values: + request.values['mimetype'] = u"text/plain" do_show(pagename, request, count_hit=0, cacheable=0) def do_content(pagename, request): @@ -283,10 +283,10 @@ def do_refresh(pagename, request): """ Handle refresh action """ # Without arguments, refresh action will refresh the page text_html cache. - arena = request.form.get('arena', 'Page.py') + arena = request.values.get('arena', 'Page.py') if arena == 'Page.py': arena = Page(request, pagename) - key = request.form.get('key', 'text_html') + key = request.values.get('key', 'text_html') # Remove cache entry (if exists), and send the page from MoinMoin import caching @@ -296,7 +296,7 @@ def do_goto(pagename, request): """ redirect to another page """ - target = request.form.get('target', '') + target = request.values.get('target', '') request.http_redirect(Page(request, target).url(request)) # Dispatching ----------------------------------------------------------------
--- a/MoinMoin/action/backup.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/backup.py Sun Nov 16 22:20:21 2008 +0100 @@ -54,7 +54,7 @@ request.emit_http_headers() request.setContentLanguage(request.lang) title = _('Wiki Backup') - request.theme.send_title(title, form=request.form, pagename=pagename) + request.theme.send_title(title, pagename=pagename) request.write(request.formatter.startContent("content")) request.write(_("""= Downloading a backup = @@ -103,7 +103,7 @@ return sendMsg(request, pagename, msg=_('You are not allowed to do remote backup.'), msgtype="error") - dowhat = request.form.get('do', [None])[0] + dowhat = request.form.get('do') if dowhat == 'backup': sendBackup(request) elif dowhat is None:
--- a/MoinMoin/action/bookmark.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/bookmark.py Sun Nov 16 22:20:21 2008 +0100 @@ -19,7 +19,7 @@ request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error") return Page(request, pagename).send_page() - timestamp = request.form.get('time') + timestamp = request.values.get('time') if timestamp is not None: if timestamp == 'del': tm = None
--- a/MoinMoin/action/cache.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/cache.py Sun Nov 16 22:20:21 2008 +0100 @@ -41,7 +41,7 @@ action_name = __name__.split('.')[-1] -# Do NOT get this directly from request.form or user would be able to read any cache! +# Do NOT get this directly from request.values or user would be able to read any cache! cache_arena = 'sendcache' # just using action_name is maybe rather confusing # We maybe could use page local caching (not 'wiki' global) to have less directory entries. @@ -239,7 +239,7 @@ _do_remove(request, key) def execute(pagename, request): - do = request.form.get('do') - key = request.form.get('key') + do = request.values.get('do') + key = request.values.get('key') _do(request, do, key)
--- a/MoinMoin/action/diff.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/diff.py Sun Nov 16 22:20:21 2008 +0100 @@ -21,7 +21,7 @@ return try: - date = request.form['date'] + date = request.values['date'] try: date = long(date) # must be long for py 2.2.x except StandardError: @@ -30,11 +30,11 @@ date = 0 try: - rev1 = int(request.form.get('rev1', -1)) + rev1 = int(request.values.get('rev1', -1)) except StandardError: rev1 = 0 try: - rev2 = int(request.form.get('rev2', 0)) + rev2 = int(request.values.get('rev2', 0)) except StandardError: rev2 = 0 @@ -44,7 +44,7 @@ rev1 = -1 # spacing flag? - ignorews = int(request.form.get('ignorews', 0)) + ignorews = int(request.values.get('ignorews', 0)) _ = request.getText
--- a/MoinMoin/action/edit.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/edit.py Sun Nov 16 22:20:21 2008 +0100 @@ -33,7 +33,7 @@ if editor not in valideditors: editor = request.cfg.editor_default - editorparam = request.form.get('editor', editor) + editorparam = request.values.get('editor', editor) if editorparam == "guipossible": lasteditor = editor elif editorparam == "textonly":
--- a/MoinMoin/action/fullsearch.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/fullsearch.py Sun Nov 16 22:20:21 2008 +0100 @@ -228,7 +228,7 @@ # This action generates data using the user language request.setContentLanguage(request.lang) - request.theme.send_title(title % needle, form=form, pagename=pagename) + request.theme.send_title(title % needle, pagename=pagename) # Start content (important for RTL support) request.write(request.formatter.startContent("content"))
--- a/MoinMoin/action/info.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/info.py Sun Nov 16 22:20:21 2008 +0100 @@ -76,7 +76,7 @@ _ = request.getText default_count, limit_max_count = request.cfg.history_count try: - max_count = int(request.form.get('max_count', [default_count])[0]) + max_count = int(request.values.get('max_count', default_count)) except: max_count = default_count max_count = min(max_count, limit_max_count) @@ -205,8 +205,8 @@ request.write("[%s] " % page.link_to(request, text=text, querystr=querystr, rel='nofollow')) request.write(f.paragraph(0)) - show_hitcounts = int(request.form.get('hitcounts', 0)) != 0 - show_general = int(request.form.get('general', 0)) != 0 + show_hitcounts = int(request.values.get('hitcounts', 0)) != 0 + show_general = int(request.values.get('general', 0)) != 0 if show_hitcounts: from MoinMoin.stats import hitcounts
--- a/MoinMoin/action/links.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/links.py Sun Nov 16 22:20:21 2008 +0100 @@ -11,14 +11,8 @@ def execute(pagename, request): _ = request.getText - form = request.form - # get the MIME type - if 'mimetype' in form: - mimetype = form['mimetype'] - else: - mimetype = "text/html" - + mimetype = request.values.get('mimetype', 'text/html') request.mimetype = mimetype if mimetype == "text/html":
--- a/MoinMoin/action/refresh.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/refresh.py Sun Nov 16 22:20:21 2008 +0100 @@ -11,10 +11,10 @@ def execute(pagename, request): """ Handle refresh action """ # Without arguments, refresh action will refresh the page text_html cache. - arena = request.form.get('arena', 'Page.py') + arena = request.values.get('arena', 'Page.py') if arena == 'Page.py': arena = Page(request, pagename) - key = request.form.get('key', 'text_html') + key = request.values.get('key', 'text_html') # Remove cache entry (if exists), and send the page from MoinMoin import caching
--- a/MoinMoin/action/rss_rc.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/rss_rc.py Sun Nov 16 22:20:21 2008 +0100 @@ -33,22 +33,22 @@ # get params items_limit = 100 try: - max_items = int(request.form['items']) + max_items = int(request.values['items']) max_items = min(max_items, items_limit) # not more than `items_limit` except (KeyError, ValueError): # not more than 15 items in a RSS file by default max_items = 15 try: - unique = int(request.form.get('unique', 0)) + unique = int(request.values.get('unique', 0)) except ValueError: unique = 0 try: - diffs = int(request.form.get('diffs', 0)) + diffs = int(request.values.get('diffs', 0)) except ValueError: diffs = 0 ## ddiffs inserted by Ralf Zosel <ralf@zosel.com>, 04.12.2003 try: - ddiffs = int(request.form.get('ddiffs', 0)) + ddiffs = int(request.values.get('ddiffs', 0)) except ValueError: ddiffs = 0
--- a/MoinMoin/action/sitemap.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/sitemap.py Sun Nov 16 22:20:21 2008 +0100 @@ -62,7 +62,6 @@ def execute(pagename, request): _ = request.getText - form = request.form request.user.datetime_fmt = datetime_fmt request.mimetype ='text/xml' @@ -86,7 +85,7 @@ # Get page dict readable by current user try: - underlay = int(form.get('underlay', 1)) + underlay = int(request.values.get('underlay', 1)) except ValueError: underlay = 1 pages = request.rootpage.getPageDict(include_underlay=underlay)
--- a/MoinMoin/action/titleindex.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/action/titleindex.py Sun Nov 16 22:20:21 2008 +0100 @@ -14,13 +14,8 @@ def execute(pagename, request): - form = request.form - # get the MIME type - if 'mimetype' in form: - mimetype = form['mimetype'] - else: - mimetype = "text/plain" + mimetype = request.values.get('mimetype', "text/plain") request.mimetype = mimetype # Get list of user readable pages
--- a/MoinMoin/macro/AdvancedSearch.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/macro/AdvancedSearch.py Sun Nov 16 22:20:21 2008 +0100 @@ -46,7 +46,7 @@ @param default: value if not present (default: '') @param escaped: if True, escape value so it can be used for html generation (default: False) """ - value = request.form.get(name, default) + value = request.values.get(name, default) if escaped: value = wikiutil.escape(value, quote=True) return value
--- a/MoinMoin/macro/Navigation.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/macro/Navigation.py Sun Nov 16 22:20:21 2008 +0100 @@ -77,7 +77,7 @@ self.pagename = self.macro.formatter.page.page_name self.print_mode = self.macro.request.action == 'print' - self.media = self.macro.request.form.get('media', [None])[0] + self.media = self.macro.request.values.get('media') self.querystr = self.print_mode and self.PROJECTION or {}
--- a/MoinMoin/macro/RecentChanges.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/macro/RecentChanges.py Sun Nov 16 22:20:21 2008 +0100 @@ -172,7 +172,7 @@ last_edits.sort() # set max size in days - max_days = min(int(request.form.get('max_days', [0])[0]), _DAYS_SELECTION[-1]) + max_days = min(int(request.values.get('max_days', 0)), _DAYS_SELECTION[-1]) # default to _MAX_DAYS for users without bookmark if not max_days: max_days = _MAX_DAYS @@ -269,7 +269,7 @@ d['rc_update_bookmark'] = page.link_to(request, _("Set bookmark"), querystr={'action': 'bookmark', 'time': '%d' % version}, rel='nofollow') # set max size in days - max_days = min(int(request.form.get('max_days', [0])[0]), _DAYS_SELECTION[-1]) + max_days = min(int(request.values.get('max_days', 0)), _DAYS_SELECTION[-1]) # default to _MAX_DAYS for useres without bookmark if not max_days and not bookmark_usecs: max_days = _MAX_DAYS
--- a/MoinMoin/macro/SystemAdmin.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/macro/SystemAdmin.py Sun Nov 16 22:20:21 2008 +0100 @@ -25,7 +25,7 @@ 'attachments': (_("File attachment browser"), do_admin_browser), 'users': (_("User account browser"), do_user_browser), } - choice = request.form.get('sysadm', [None])[0] + choice = request.values.get('sysadm') # create menu menuitems = [(label, fnid) for fnid, (label, handler) in _MENU.items()]
--- a/MoinMoin/macro/WantedPages.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/macro/WantedPages.py Sun Nov 16 22:20:21 2008 +0100 @@ -21,7 +21,7 @@ return '' # Get allpages switch from the form - allpages = int(request.form.get('allpages', [0])[0]) != 0 + allpages = int(request.values.get('allpages', 0)) != 0 # Control bar - filter the list of pages # TODO: we should make this a widget and use on all page listing pages
--- a/MoinMoin/macro/__init__.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/macro/__init__.py Sun Nov 16 22:20:21 2008 +0100 @@ -192,7 +192,7 @@ _ = self._ request = self.request fmt = self.formatter - allpages = int(self.form.get('allpages', [0])[0]) != 0 + allpages = int(request.values.get('allpages', 0)) != 0 # Get page list readable by current user, filter by isSystemPage if needed if allpages: pages = request.rootpage.getPageList()
--- a/MoinMoin/script/maint/mailtranslators.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/script/maint/mailtranslators.py Sun Nov 16 22:20:21 2008 +0100 @@ -50,7 +50,6 @@ def mainloop(self): self.init_request() request = self.request - request.form = request.args = request.setup_args() from_address = unicode(self.options.from_address or "tw-public@gmx.de") subject = unicode(self.options.subject or "MoinMoin i18n notification")
--- a/MoinMoin/script/maint/mkpagepacks.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/script/maint/mkpagepacks.py Sun Nov 16 22:20:21 2008 +0100 @@ -157,7 +157,6 @@ self.init_request() # this request will work on a test wiki in tests/wiki/ directory # we assume that there are current moinmaster pages there request = self.request - request.form = request.args = request.setup_args() if not ('tests/wiki' in request.cfg.data_dir.replace("\\", "/") and 'tests/wiki' in request.cfg.data_underlay_dir.replace("\\", "/")): import sys
--- a/MoinMoin/script/maint/reducewiki.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/script/maint/reducewiki.py Sun Nov 16 22:20:21 2008 +0100 @@ -84,7 +84,6 @@ def mainloop(self): self.init_request() request = self.request - request.form = request.args = request.setup_args() destdir = self.options.target_dir pagelist = list(request.rootpage.getPageList(user='')) for pagename in pagelist:
--- a/MoinMoin/security/textcha.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/security/textcha.py Sun Nov 16 22:20:21 2008 +0100 @@ -141,8 +141,8 @@ def _extract_form_values(self, form=None): if form is None: form = self.request.form - question = form.get('textcha-question', [None])[0] - given_answer = form.get('textcha-answer', [u''])[0] + question = form.get('textcha-question') + given_answer = form.get('textcha-answer', u'') return question, given_answer def render(self, form=None):
--- a/MoinMoin/theme/__init__.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/theme/__init__.py Sun Nov 16 22:20:21 2008 +0100 @@ -738,10 +738,10 @@ @return: search form html """ _ = self.request.getText - form = self.request.form + form = self.request.values updates = { 'search_label': _('Search:'), - 'search_value': wikiutil.escape(form.get('value', [''])[0], 1), + 'search_value': wikiutil.escape(form.get('value', ''), 1), 'search_full_label': _('Text'), 'search_title_label': _('Titles'), 'url': self.request.href(d['page'].page_name)
--- a/MoinMoin/util/web.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/util/web.py Sun Nov 16 22:20:21 2008 +0100 @@ -14,7 +14,7 @@ is missing). """ try: - result = int(request.form[fieldname]) + result = int(request.values[fieldname]) except (KeyError, ValueError): return default else:
--- a/MoinMoin/xmlrpc/UpdateGroup.py Sun Nov 16 16:50:56 2008 +0100 +++ b/MoinMoin/xmlrpc/UpdateGroup.py Sun Nov 16 22:20:21 2008 +0100 @@ -55,7 +55,7 @@ logging.debug("saveText msg: %s" % msg) #we need this to update pagelinks cache: - self.request.args = self.request.form = self.request.setup_args() + #self.request.args = self.request.form = self.request.setup_args() self.request.redirectedOutput(page.send_page, content_only=1) return xmlrpclib.Boolean(1)