diff MoinMoin/action/edit.py @ 1868:64507f46beb2

reduce usage of has_key()
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 10 Mar 2007 22:01:07 +0100
parents 0194beaf511e
children 46e859ee4d2e
line wrap: on
line diff
--- a/MoinMoin/action/edit.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/edit.py	Sat Mar 10 22:01:07 2007 +0100
@@ -15,7 +15,7 @@
     """ edit a page """
     _ = request.getText
 
-    if request.form.has_key('button_preview') and request.form.has_key('button_spellcheck'):
+    if 'button_preview' in request.form and 'button_spellcheck' in request.form:
         # multiple buttons pressed at once? must be some spammer/bot
         request.makeForbidden403()
         request.surge_protect(kick_him=True) # get rid of him
@@ -56,7 +56,7 @@
     rstrip = int(request.form.get('rstrip', ['0'])[0])
     trivial = int(request.form.get('trivial', ['0'])[0])
 
-    if request.form.has_key('button_switch'):
+    if 'button_switch' in request.form:
         if editor == 'text':
             editor = 'gui'
         else: # 'gui'
@@ -71,12 +71,12 @@
         pg = PageEditor(request, pagename)
 
     # is invoked without savetext start editing
-    if savetext is None or request.form.has_key('button_load_draft'):
+    if savetext is None or 'button_load_draft' in request.form:
         pg.sendEditor()
         return
 
     # did user hit cancel button?
-    cancelled = request.form.has_key('button_cancel')
+    cancelled = 'button_cancel' in request.form
 
     if request.cfg.edit_ticketing:
         ticket = request.form.get('ticket', [''])[0]
@@ -137,13 +137,13 @@
         savetext += category + u'\n' # Should end with newline!
 
     # Preview, spellcheck or spellcheck add new words
-    if (request.form.has_key('button_preview') or
-        request.form.has_key('button_spellcheck') or
-        request.form.has_key('button_newwords')):
+    if ('button_preview' in request.form or
+        'button_spellcheck' in request.form or
+        'button_newwords' in request.form):
         pg.sendEditor(preview=savetext, comment=comment)
 
     # Preview with mode switch
-    elif request.form.has_key('button_switch'):
+    elif 'button_switch' in request.form:
         pg.sendEditor(preview=savetext, comment=comment, staytop=1)
 
     # Save new text