changeset 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 8166b37db555
children 88326c62ae53
files MoinMoin/Page.py MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py MoinMoin/action/AttachFile.py MoinMoin/action/DeletePage.py MoinMoin/action/Load.py MoinMoin/action/LocalSiteMap.py MoinMoin/action/PackagePages.py MoinMoin/action/RenamePage.py MoinMoin/action/SpellCheck.py MoinMoin/action/SubscribeUser.py MoinMoin/action/__init__.py MoinMoin/action/edit.py MoinMoin/action/fckdialog.py MoinMoin/action/fullsearch.py MoinMoin/action/links.py MoinMoin/action/titleindex.py MoinMoin/auth/__init__.py MoinMoin/config/multiconfig.py MoinMoin/converter/text_html_text_moin_wiki.py MoinMoin/filter/EXIF.py MoinMoin/formatter/__init__.py MoinMoin/formatter/text_gedit.py MoinMoin/formatter/text_html.py MoinMoin/formatter/text_plain.py MoinMoin/i18n/tools/check_i18n.py MoinMoin/logfile/editlog.py MoinMoin/macro/FullSearch.py MoinMoin/macro/ImageLink.py MoinMoin/macro/Include.py MoinMoin/macro/MonthCalendar.py MoinMoin/macro/SystemAdmin.py MoinMoin/macro/TeudView.py MoinMoin/parser/text_moin_wiki.py MoinMoin/request/__init__.py MoinMoin/stats/hitcounts.py MoinMoin/support/thfcgi.py MoinMoin/user.py MoinMoin/util/web.py MoinMoin/widget/html.py MoinMoin/wikiutil.py contrib/auth_externalcookie/wikiconfig.py
diffstat 42 files changed, 110 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/Page.py	Sat Mar 10 22:01:07 2007 +0100
@@ -889,9 +889,9 @@
         _ = request.getText
         emit_headers = keywords.get('emit_headers', 1)
         # determine modes
-        print_mode = request.form.has_key('action') and request.form['action'][0] == 'print'
+        print_mode = 'action' in request.form and request.form['action'][0] == 'print'
         if print_mode:
-            media = request.form.has_key('media') and request.form['media'][0] or 'print'
+            media = 'media' in request.form and request.form['media'][0] or 'print'
         else:
             media = 'screen'
         content_only = keywords.get('content_only', 0)
@@ -997,7 +997,8 @@
                 # endless looping (see code in "request") or any
                 # cascaded redirection
                 pi_redirect = args
-                if request.form.has_key('action') or request.form.has_key('redirect') or content_only: continue
+                if 'action' in request.form or 'redirect' in request.form or content_only:
+                    continue
 
                 request.http_redirect('%s/%s?action=show&redirect=%s' % (
                     request.getScriptname(),
@@ -1079,7 +1080,7 @@
 
                 # This redirect message is very annoying.
                 # Less annoying now without the warning sign.
-                if request.form.has_key('redirect'):
+                if 'redirect' in request.form:
                     redir = request.form['redirect'][0]
                     msg = '<strong>%s</strong><br>%s' % (
                         _('Redirected from page "%(page)s"') % {'page':
--- a/MoinMoin/PageEditor.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/PageEditor.py	Sat Mar 10 22:01:07 2007 +0100
@@ -189,7 +189,7 @@
 
         # check if we want to load a draft
         use_draft = None
-        if form.has_key('button_load_draft'):
+        if 'button_load_draft' in form:
             wanted_draft_timestamp = int(form.get('draft_ts', ['0'])[0])
             if wanted_draft_timestamp:
                 draft = self._load_draft()
@@ -264,7 +264,7 @@
             # 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 form.has_key('template'):
+        elif 'template' in form:
             # If the page does not exists, we try to get the content from the template parameter.
             template_page = wikiutil.unquoteWikiname(form['template'][0])
             if request.user.may.read(template_page):
@@ -444,8 +444,8 @@
         badwords_re = None
         if preview is not None:
             if SpellCheck and (
-                    form.has_key('button_spellcheck') or
-                    form.has_key('button_newwords')):
+                    'button_spellcheck' in form or
+                    'button_newwords' in form):
                 badwords, badwords_re, msg = SpellCheck.checkSpelling(self, request, own_form=0)
                 request.write("<p>%s</p>" % msg)
         request.write('</fieldset>')
@@ -950,8 +950,8 @@
         """
         request = self.request
         _ = self._
-        #is_deprecated = self._get_pragmas(text).has_key("deprecated")
-        was_deprecated = self._get_pragmas(self.get_raw_body()).has_key("deprecated")
+        #is_deprecated = "deprecated" in self._get_pragmas(text)
+        was_deprecated = "deprecated" in self._get_pragmas(self.get_raw_body())
 
         self.copy_underlay_page()
 
--- a/MoinMoin/PageGraphicalEditor.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/PageGraphicalEditor.py	Sat Mar 10 22:01:07 2007 +0100
@@ -85,7 +85,7 @@
 
         # check if we want to load a draft
         use_draft = None
-        if form.has_key('button_load_draft'):
+        if 'button_load_draft' in form:
             wanted_draft_timestamp = int(form.get('draft_ts', ['0'])[0])
             if wanted_draft_timestamp:
                 draft = self._load_draft()
@@ -162,7 +162,7 @@
             # 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 form.has_key('template'):
+        elif 'template' in form:
             # If the page does not exists, we try to get the content from the template parameter.
             template_page = wikiutil.unquoteWikiname(form['template'][0])
             if request.user.may.read(template_page):
@@ -370,8 +370,8 @@
         badwords_re = None
         if preview is not None:
             if SpellCheck and (
-                    form.has_key('button_spellcheck') or
-                    form.has_key('button_newwords')):
+                    'button_spellcheck' in form or
+                    'button_newwords' in form):
                 badwords, badwords_re, msg = SpellCheck.checkSpelling(self, request, own_form=0)
                 request.write("<p>%s</p>" % msg)
         request.write('</fieldset>')
--- a/MoinMoin/action/AttachFile.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/AttachFile.py	Sat Mar 10 22:01:07 2007 +0100
@@ -177,7 +177,7 @@
     #type, encoding = wikiutil.guess_type(target)
     #if not type:
     #    ext = None
-    #    if request.form.has_key('mime'):
+    #    if 'mime' in request.form:
     #        ext = wikiutil.guess_extension(request.form['mime'][0])
     #    if not ext:
     #        type, encoding = wikiutil.guess_type(filename)
@@ -529,7 +529,7 @@
     msg = None
     if action_name in request.cfg.actions_excluded:
         msg = _('File attachments are not allowed in this wiki!')
-    elif not request.form.has_key('do'):
+    elif 'do' not in request.form:
         upload_form(pagename, request)
     elif request.form['do'][0] == 'savedrawing':
         if request.user.may.write(pagename):
@@ -540,7 +540,7 @@
             msg = _('You are not allowed to save a drawing on this page.')
     elif request.form['do'][0] == 'upload':
         if request.user.may.write(pagename):
-            if request.form.has_key('file'):
+            if 'file' in request.form:
                 do_upload(pagename, request)
             else:
                 # This might happen when trying to upload file names
@@ -559,7 +559,7 @@
         else:
             msg = _('You are not allowed to move attachments from this page.')
     elif request.form['do'][0] == 'attachment_move':
-        if request.form.has_key('cancel'):
+        if 'cancel' in request.form:
             msg = _('Move aborted!')
             error_msg(pagename, request, msg)
             return
@@ -615,13 +615,13 @@
 
     # make filename
     filename = None
-    if request.form.has_key('file__filename__'):
+    if 'file__filename__' in request.form:
         filename = request.form['file__filename__']
     rename = None
-    if request.form.has_key('rename'):
+    if 'rename' in request.form:
         rename = request.form['rename'][0].strip()
     overwrite = 0
-    if request.form.has_key('overwrite'):
+    if 'overwrite' in request.form:
         try:
             overwrite = int(request.form['overwrite'][0])
         except:
@@ -744,11 +744,11 @@
 
 def attachment_move(pagename, request):
     _ = request.getText
-    if request.form.has_key('newpagename'):
+    if 'newpagename' in request.form:
         new_pagename = request.form.get('newpagename')[0]
     else:
         upload_form(pagename, request, msg=_("Move aborted because empty page name"))
-    if request.form.has_key('newattachmentname'):
+    if 'newattachmentname' in request.form:
         new_attachment = request.form.get('newattachmentname')[0]
         if new_attachment != wikiutil.taintfilename(new_attachment):
             upload_form(pagename, request, msg=_("Please use a valid filename for attachment '%(filename)s'.") % {
--- a/MoinMoin/action/DeletePage.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/DeletePage.py	Sat Mar 10 22:01:07 2007 +0100
@@ -57,7 +57,7 @@
         success, msg = self.page.deletePage(comment)
         msgs = msg
         delete_subpages = 0
-        if form.has_key('delete_subpages'):
+        if 'delete_subpages' in form:
             try:
                 delete_subpages = int(form['delete_subpages'][0])
             except:
--- a/MoinMoin/action/Load.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/Load.py	Sat Mar 10 22:01:07 2007 +0100
@@ -37,14 +37,14 @@
         rename = form.get('rename', [u''])[0]
 
         filename = None
-        if form.has_key('file__filename__'):
+        if 'file__filename__' in form:
             filename = form['file__filename__']
 
         filecontent = form['file'][0]
         bytes = len(filecontent)
 
         overwrite = False
-        if form.has_key('overwrite'):
+        if 'overwrite' in form:
             overwrite = True
 
         target = filename
@@ -58,7 +58,7 @@
             if bsindex >= 0:
                 target = target[bsindex+1:]
 
-        if self.request.form.has_key('attachment') and self.request.user.may.write(self.pagename):
+        if 'attachment' in self.request.form and self.request.user.may.write(self.pagename):
             attach_dir = AttachFile.getAttachDir(self.request, self.pagename, create=1)
             fpath = os.path.join(attach_dir, target).encode(config.charset)
             exists = os.path.exists(fpath)
--- a/MoinMoin/action/LocalSiteMap.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/LocalSiteMap.py	Sat Mar 10 22:01:07 2007 +0100
@@ -92,7 +92,7 @@
         self.children[name] = 1
 
     def child_marked(self, name):
-        return self.children.has_key(name)
+        return name in self.children
 
     def is_ok(self, child):
         if not self.child_marked(child):
--- a/MoinMoin/action/PackagePages.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/PackagePages.py	Sat Mar 10 22:01:07 2007 +0100
@@ -44,7 +44,7 @@
         _ = self.request.getText
         form = self.request.form
 
-        if form.has_key('cancel'):
+        if 'cancel' in form:
             # User canceled
             return self.page.send_page()
 
--- a/MoinMoin/action/RenamePage.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/RenamePage.py	Sat Mar 10 22:01:07 2007 +0100
@@ -58,7 +58,7 @@
         success, msg = self.page.renamePage(newpagename, comment)
 
         rename_subpages = 0
-        if form.has_key('rename_subpages'):
+        if 'rename_subpages' in form:
             try:
                 rename_subpages = int(form['rename_subpages'][0])
             except:
--- a/MoinMoin/action/SpellCheck.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/SpellCheck.py	Sat Mar 10 22:01:07 2007 +0100
@@ -125,7 +125,7 @@
     _ = request.getText
 
     # first check to see if we we're called with a "newwords" parameter
-    if request.form.has_key('button_newwords'):
+    if 'button_newwords' in request.form:
         _addLocalWords(request)
 
     # load words
@@ -152,10 +152,8 @@
             return ""
         w_enc = word.encode(config.charset)
         wl_enc = word.lower().encode(config.charset)
-        if not (wordsdict.has_key(w_enc) or
-                wordsdict.has_key(wl_enc) or
-                localwords.has_key(w_enc) or
-                localwords.has_key(wl_enc) ):
+        if not (w_enc in wordsdict or wl_enc in wordsdict or
+                w_enc in localwords or wl_enc in localwords):
             if not num_re.match(word):
                 badwords[word] = 1
         return ""
--- a/MoinMoin/action/SubscribeUser.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/SubscribeUser.py	Sat Mar 10 22:01:07 2007 +0100
@@ -87,7 +87,7 @@
     if not request.user.may.admin(pagename):
         thispage = Page(request, pagename)
         return thispage.send_page(msg=_("You are not allowed to perform this action."))
-    elif not request.form.has_key('users'):
+    elif 'users' not in request.form:
         show_form(pagename, request)
     else:
         show_result(pagename, request)
--- a/MoinMoin/action/__init__.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/__init__.py	Sat Mar 10 22:01:07 2007 +0100
@@ -169,7 +169,7 @@
         _ = self._
         form = self.form
 
-        if form.has_key(self.form_cancel):
+        if self.form_cancel in form:
             self.render_cancel()
             return
 
@@ -183,7 +183,7 @@
             error = self.check_condition()
         if error:
             self.render_msg(error)
-        elif form.has_key(self.form_trigger): # user hit the trigger button
+        elif self.form_trigger in form: # user hit the trigger button
             if self.ticket_ok():
                 success, self.error = self.do_action()
             else:
@@ -240,7 +240,7 @@
         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 not request.form.has_key('mimetype'):
+    if 'mimetype' not in request.form:
         request.form['mimetype'] = [u"text/plain"]
     do_show(pagename, request, count_hit=0, cacheable=0)
 
--- 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
--- a/MoinMoin/action/fckdialog.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/fckdialog.py	Sat Mar 10 22:01:07 2007 +0100
@@ -95,7 +95,7 @@
             selected = ' selected="selected"'
         else:
             selected = ''
-        if help.has_key(macro):
+        if macro in help:
             macros.append('<option value="%s"%s>%s</option>' %
                           (help[macro].group('prototype'), selected, macro))
         else:
@@ -110,7 +110,7 @@
 
     helptexts = []
     for macro in macro_list(request):
-        if help.has_key(macro):
+        if macro in help:
             match = help[macro]
             prototype = match.group('prototype')
             helptext = match.group('help')
--- a/MoinMoin/action/fullsearch.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/fullsearch.py	Sat Mar 10 22:01:07 2007 +0100
@@ -23,7 +23,7 @@
     True (might happen with Safari) if this isn't an advanced search.
 """
     form = request.form
-    if form.has_key('titlesearch') and form.has_key('fullsearch'):
+    if 'titlesearch' in form and 'fullsearch' in form:
         ret = -1 # spammer / bot
     else:
         try:
--- a/MoinMoin/action/links.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/links.py	Sat Mar 10 22:01:07 2007 +0100
@@ -14,7 +14,7 @@
     form = request.form
 
     # get the MIME type
-    if form.has_key('mimetype'):
+    if 'mimetype' in form:
         mimetype = form['mimetype'][0]
     else:
         mimetype = "text/html"
--- a/MoinMoin/action/titleindex.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/action/titleindex.py	Sat Mar 10 22:01:07 2007 +0100
@@ -17,7 +17,7 @@
     form = request.form
 
     # get the MIME type
-    if form.has_key('mimetype'):
+    if 'mimetype' in form:
         mimetype = form['mimetype'][0]
     else:
         mimetype = "text/plain"
--- a/MoinMoin/auth/__init__.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/auth/__init__.py	Sat Mar 10 22:01:07 2007 +0100
@@ -218,7 +218,7 @@
         if verbose: request.log("caught Cookie.CookieError")
         cookie = None
 
-    if not (cookie is not None and cookie.has_key(cookie_name)):
+    if not (cookie is not None and cookie_name in cookie):
         # No valid cookie
         if verbose: request.log("either no cookie or no %s key" % cookie_name)
         return user_obj, True
--- a/MoinMoin/config/multiconfig.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/config/multiconfig.py	Sat Mar 10 22:01:07 2007 +0100
@@ -677,7 +677,7 @@
         """
         unknown = ['"%s"' % name for name in dir(self)
                   if not name.startswith('_') and
-                  not DefaultConfig.__dict__.has_key(name) and
+                  name not in DefaultConfig.__dict__ and
                   not isinstance(getattr(self, name), (type(sys), type(DefaultConfig)))]
         if unknown:
             msg = """
@@ -822,7 +822,7 @@
         """
         # user checkbox defaults
         for key, value in DefaultConfig.user_checkbox_defaults.items():
-            if not self.user_checkbox_defaults.has_key(key):
+            if key not in self.user_checkbox_defaults:
                 self.user_checkbox_defaults[key] = value
 
     def __getitem__(self, item):
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Mar 10 22:01:07 2007 +0100
@@ -1095,9 +1095,9 @@
         if href:
             title = class_ = interwikiname = None
 
-            if node.attributes.has_key("title"):
+            if "title" in node.attributes:
                 title = node.attributes.get("title").nodeValue
-            if node.attributes.has_key("class"):
+            if "class" in node.attributes:
                 class_ = node.attributes.get("class").nodeValue
 
             text = self.node_list_text_only(node.childNodes)
@@ -1179,22 +1179,22 @@
 
     def process_img(self, node):
         src = None
-        if node.attributes.has_key("src"):
+        if "src" in node.attributes:
             src = wikiutil.url_unquote(node.attributes.get("src").nodeValue)
         title = None
-        if node.attributes.has_key("title"):
+        if "title" in node.attributes:
             title = node.attributes.get("title").nodeValue
         alt = None
-        if node.attributes.has_key("alt"):
+        if "alt" in node.attributes:
             alt = node.attributes.get("alt").nodeValue
         width = None
-        if node.attributes.has_key("width"):
+        if "width" in node.attributes:
             width = node.attributes.get("width").nodeValue
         height = None
-        if node.attributes.has_key("height"):
+        if "height" in node.attributes:
             height = node.attributes.get("height").nodeValue
         target = None
-        if node.attributes.has_key("target"):
+        if "target" in node.attributes:
             target = node.attributes.get("target").nodeValue
 
         # Attachment image
--- a/MoinMoin/filter/EXIF.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/filter/EXIF.py	Sat Mar 10 22:01:07 2007 +0100
@@ -1155,12 +1155,12 @@
         hdr.tags['JPEGThumbnail'] = file.read(size)
 
     # deal with MakerNote contained in EXIF IFD
-    if hdr.tags.has_key('EXIF MakerNote'):
+    if 'EXIF MakerNote' in hdr.tags:
         hdr.decode_maker_note()
 
     # Sometimes in a TIFF file, a JPEG thumbnail is hidden in the MakerNote
     # since it's not allowed in a uncompressed TIFF IFD
-    if not hdr.tags.has_key('JPEGThumbnail'):
+    if 'JPEGThumbnail' not in hdr.tags:
         thumb_off = hdr.tags.get('MakerNote JPEGThumbnail')
         if thumb_off:
             file.seek(offset+thumb_off.values[0])
@@ -1199,6 +1199,6 @@
                       (i, FIELD_TYPES[data[i].field_type][2], data[i].printable)
             except:
                 print 'error', i, '"', data[i], '"'
-        if data.has_key('JPEGThumbnail'):
+        if 'JPEGThumbnail' in data:
             print 'File has JPEG thumbnail'
         print
--- a/MoinMoin/formatter/__init__.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/formatter/__init__.py	Sat Mar 10 22:01:07 2007 +0100
@@ -158,7 +158,7 @@
         """
         title = src
         for titleattr in ('title', 'html__title', 'alt', 'html__alt'):
-            if kw.has_key(titleattr):
+            if titleattr in kw:
                 title = kw[titleattr]
                 break
         if title:
--- a/MoinMoin/formatter/text_gedit.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/formatter/text_gedit.py	Sat Mar 10 22:01:07 2007 +0100
@@ -165,7 +165,7 @@
         }
 
     def _style_to_attributes(self, attrs):
-        if not attrs.has_key('style'):
+        if 'style' not in attrs:
             return attrs
         unknown = []
         for entry in attrs['style'].split(';'):
@@ -175,7 +175,7 @@
                 unknown.append(entry)
                 continue
             key, value = key.strip(), value.strip()
-            if self.style2attribute.has_key(key):
+            if key in self.style2attribute:
                 attrs[self.style2attribute[key]] = value
             else:
                 unknown.append("%s:%s" % (key, value))
--- a/MoinMoin/formatter/text_html.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/formatter/text_html.py	Sat Mar 10 22:01:07 2007 +0100
@@ -151,10 +151,10 @@
 
     key = ns, name
     if value is None:
-        if attributedict.has_key(key):
+        if key in attributedict:
             del attributedict[key]
     else:
-        if ns == 'html' and attributedict.has_key(key):
+        if ns == 'html' and key in attributedict:
             if name == 'class':
                 # CSS classes are appended by space-separated list
                 value = attributedict[key] + ' ' + value
@@ -274,15 +274,15 @@
                 extend_attribute_dictionary(attributes, a_ns, a_name, v)
 
         # Add title attribute if missing, but it has an alt.
-        if attributes.has_key(('html', 'alt')) and not attributes.has_key(('html', 'title')):
+        if ('html', 'alt') in attributes and ('html', 'title') not in attributes:
             attributes[('html', 'title')] = attributes[('html', 'alt')]
 
         # Force both lang and xml:lang to be present and identical if
         # either exists.  The lang takes precedence over xml:lang if
         # both exist.
-        #if attributes.has_key(('html', 'lang')):
+        #if ('html', 'lang') in attributes:
         #    attributes[('xml', 'lang')] = attributes[('html', 'lang')]
-        #elif attributes.has_key(('xml', 'lang')):
+        #elif ('xml', 'lang') in attributes:
         #    attributes[('html', 'lang')] = attributes[('xml', 'lang')]
 
         # Check all the HTML attributes to see if they are known and
@@ -559,7 +559,7 @@
             attrs = self._langAttr()
 
             # Handle the URL mapping
-            if url is None and kw.has_key('href'):
+            if url is None and 'href' in kw:
                 url = kw['href']
                 del kw['href']
             if url is not None:
@@ -612,7 +612,7 @@
         attrs = self._langAttr()
         if name:
             attrs['href'] = '#%s' % name
-        if kw.has_key('href'):
+        if 'href' in kw:
             del kw['href']
         if on:
             str = self._open('a', attr=attrs, **kw)
--- a/MoinMoin/formatter/text_plain.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/formatter/text_plain.py	Sat Mar 10 22:01:07 2007 +0100
@@ -75,7 +75,7 @@
     def attachment_image(self, url, **kw):
         title = ''
         for a in (u'title', u'html__title', u'alt', u'html_alt'):
-            if kw.has_key(a):
+            if a in kw:
                 title = ':' + kw[a]
         return "[image:%s%s]" % (url, title)
 
@@ -243,7 +243,7 @@
 
     def image(self, src=None, **kw):
         for a in (u'title', u'html__title', u'alt', u'html_alt'):
-            if kw.has_key(a):
+            if a in kw:
                 return kw[a]
         return u''
 
--- a/MoinMoin/i18n/tools/check_i18n.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/i18n/tools/check_i18n.py	Sat Mar 10 22:01:07 2007 +0100
@@ -90,7 +90,7 @@
 
     def walk(self, node):
         """ Walk through all nodes """
-        if self._visited.has_key(node):
+        if node in self._visited:
             # We visited this node already
             return
             
@@ -140,12 +140,12 @@
         self._found = self._found + 1
 
         # Create key for this text if needed
-        if not self._dictionary.has_key(text):
+        if text not in self._dictionary:
             self._dictionary[text] = {}
 
         # Create key for this filename if needed   
         textInfo = self._dictionary[text]
-        if not textInfo.has_key(self._filename):
+        if self._filename not in textInfo:
             textInfo[self._filename] = [self._lineno]
         else:
             textInfo[self._filename].append(self._lineno)
@@ -205,12 +205,12 @@
 
         # Collect missing texts
         for text in self.__sourceDict:
-            if not self.__langDict.has_key(text):
+            if text not in self.__langDict:
                 self.__missing[text] = self.__sourceDict[text]
 
         # Collect unused texts
         for text in self.__langDict:
-            if not self.__sourceDict.has_key(text):
+            if text not in self.__sourceDict:
                 self.__unused[text] = self.__langDict[text]
         self.__ready = 1
         
--- a/MoinMoin/logfile/editlog.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/logfile/editlog.py	Sat Mar 10 22:01:07 2007 +0100
@@ -51,7 +51,7 @@
         """
         result = 'ip', request.cfg.show_hosts and self.hostname or ''
         if self.userid:
-            if not self._usercache.has_key(self.userid):
+            if self.userid not in self._usercache:
                 self._usercache[self.userid] = user.User(request, self.userid, auth_method="editlog:53")
             userdata = self._usercache[self.userid]
             if userdata.name:
@@ -73,7 +73,7 @@
         """
         result = 'ip', request.cfg.show_hosts and self.hostname or ''
         if self.userid:
-            if not self._usercache.has_key(self.userid):
+            if self.userid not in self._usercache:
                 self._usercache[self.userid] = user.User(request, self.userid, auth_method="editlog:75")
             userdata = self._usercache[self.userid]
             if userdata.mailto_author and userdata.email:
@@ -200,10 +200,10 @@
     def set_filter(self, **kw):
         expr = "1"
         for field in ['pagename', 'addr', 'hostname', 'userid']:
-            if kw.has_key(field):
+            if field in kw:
                 expr = "%s and x.%s == %s" % (expr, field, repr(kw[field]))
 
-        if kw.has_key('ed_time_usecs'):
+        if 'ed_time_usecs' in kw:
             expr = "%s and long(x.ed_time_usecs) == %s" % (expr, long(kw['ed_time_usecs'])) # must be long for py 2.2.x
 
         self.filter = eval("lambda x: " + expr)
--- a/MoinMoin/macro/FullSearch.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/macro/FullSearch.py	Sat Mar 10 22:01:07 2007 +0100
@@ -42,7 +42,7 @@
     @return: search box html fragment
     """
     _ = macro._
-    if macro.form.has_key('value'):
+    if 'value' in macro.form:
         default = wikiutil.escape(macro.form["value"][0], quote=1)
     else:
         default = ''
--- a/MoinMoin/macro/ImageLink.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/macro/ImageLink.py	Sat Mar 10 22:01:07 2007 +0100
@@ -174,7 +174,7 @@
                                          wikiutil.url_quote_plus(attname))),
                                          linktext % {'filename': attname})
 
-    if not kw.has_key('alt'):
+    if 'alt' not in kw:
         if target is None or _is_URL(target):
             if _is_URL(image):
                 # Get image name http://here.com/dir/image.png -> image.png
--- a/MoinMoin/macro/Include.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/macro/Include.py	Sat Mar 10 22:01:07 2007 +0100
@@ -100,7 +100,7 @@
     for inc_name in pagelist:
         if not request.user.may.read(inc_name):
             continue
-        if this_page._macroInclude_pagelist.has_key(inc_name):
+        if inc_name in this_page._macroInclude_pagelist:
             result.append(u'<p><strong class="error">Recursive include of "%s" forbidden</strong></p>' % (inc_name,))
             continue
         if skipitems:
--- a/MoinMoin/macro/MonthCalendar.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/macro/MonthCalendar.py	Sat Mar 10 22:01:07 2007 +0100
@@ -258,7 +258,7 @@
     currentyear, currentmonth, currentday, h, m, s, wd, yd, ds = request.user.getTime(time.time())
     thispage = formatter.page.page_name
     # does the url have calendar params (= somebody has clicked on prev/next links in calendar) ?
-    if macro.form.has_key('calparms'):
+    if 'calparms' in macro.form:
         text2 = macro.form['calparms'][0]
         args2 = args_re.match(text2)
         if not args2:
--- a/MoinMoin/macro/SystemAdmin.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/macro/SystemAdmin.py	Sat Mar 10 22:01:07 2007 +0100
@@ -44,7 +44,7 @@
     result.append(f.linebreak())
 
     # add chosen content
-    if _MENU.has_key(choice):
+    if choice in _MENU:
         result.append(f.rawHTML(_MENU[choice][1](request)))
 
     return ''.join(result)
--- a/MoinMoin/macro/TeudView.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/macro/TeudView.py	Sat Mar 10 22:01:07 2007 +0100
@@ -33,7 +33,7 @@
     xslfile = xmldoc.getDataPath('webde.xsl')
     pagename = macro.formatter.page.page_name
 
-    if macro.form.has_key('module'):
+    if 'module' in macro.form:
         modname = macro.form["module"][0]
         try:
             object = pydoc.locate(modname)
--- a/MoinMoin/parser/text_moin_wiki.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/parser/text_moin_wiki.py	Sat Mar 10 22:01:07 2007 +0100
@@ -748,11 +748,11 @@
 
             # check for adjacent cell markers
             if word.count("|") > 2:
-                if not attrs.has_key('align') and \
-                   not (attrs.has_key('style') and 'text-align' in attrs['style'].lower()):
+                if 'align' not in attrs and \
+                   not ('style' in attrs and 'text-align' in attrs['style'].lower()):
                     # add center alignment if we don't have some alignment already
                     attrs['align'] = '"center"'
-                if not attrs.has_key('colspan'):
+                if 'colspan' not in attrs:
                     attrs['colspan'] = '"%d"' % (word.count("|")/2)
 
             # return the complete cell markup
--- a/MoinMoin/request/__init__.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/request/__init__.py	Sat Mar 10 22:01:07 2007 +0100
@@ -562,8 +562,8 @@
         """ read the maybe present UserPreferences form and call get_user with the values """
         name = self.form.get('name', [None])[0]
         password = self.form.get('password', [None])[0]
-        login = self.form.has_key('login')
-        logout = self.form.has_key('logout')
+        login = 'login' in self.form
+        logout = 'logout' in self.form
         u = self.get_user_default_unknown(name=name, password=password,
                                           login=login, logout=logout,
                                           user_obj=None)
--- a/MoinMoin/stats/hitcounts.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/stats/hitcounts.py	Sat Mar 10 22:01:07 2007 +0100
@@ -140,7 +140,7 @@
         params = params[len('page='):]
         filterpage = wikiutil.decodeUserInput(params)
 
-    if request and request.form and request.form.has_key('page'):
+    if request and request.form and 'page' in request.form:
         filterpage = request.form['page'][0]
 
     days, views, edits = get_data(pagename, request, filterpage)
@@ -190,7 +190,7 @@
 
     # check params
     filterpage = None
-    if request and request.form and request.form.has_key('page'):
+    if request and request.form and 'page' in request.form:
         filterpage = request.form['page'][0]
 
     days, views, edits = get_data(pagename, request, filterpage)
--- a/MoinMoin/support/thfcgi.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/support/thfcgi.py	Sat Mar 10 22:01:07 2007 +0100
@@ -408,7 +408,7 @@
                      }
 
             for name in rec.values.keys():
-                if params.has_key(name):
+                if name in params:
                     # We known this value, include in reply
                     reply_rec.values[name] = params[name]
 
@@ -571,7 +571,7 @@
     def _check_good_addrs(self, addr):
         """Check if request is done from the right server."""
         # Apaches mod_fastcgi seems not to use FCGI_WEB_SERVER_ADDRS. 
-        if os.environ.has_key('FCGI_WEB_SERVER_ADDRS'):
+        if 'FCGI_WEB_SERVER_ADDRS' in os.environ:
             good_addrs = os.environ['FCGI_WEB_SERVER_ADDRS'].split(',')
             good_addrs = [addr.strip() for addr in good_addrs] # Remove whitespace
         else:
--- a/MoinMoin/user.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/user.py	Sat Mar 10 22:01:07 2007 +0100
@@ -378,7 +378,7 @@
 
         # Remove ignored checkbox values from user data
         for key, label in self._cfg.user_checkbox_fields:
-            if user_data.has_key(key) and key in self._cfg.user_checkbox_disable:
+            if key in user_data and key in self._cfg.user_checkbox_disable:
                 del user_data[key]
 
         # Copy user data into user object
--- a/MoinMoin/util/web.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/util/web.py	Sat Mar 10 22:01:07 2007 +0100
@@ -232,7 +232,7 @@
             self.r = (color >> 16) & 255
             self.g = (color >> 8) & 255
             self.b = color & 255
-        elif not self.COLORS.has_key(color):
+        elif color not in self.COLORS:
             raise ValueError("Unknown color name '%s'" % color)
         else:
             # known color name
--- a/MoinMoin/widget/html.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/widget/html.py	Sat Mar 10 22:01:07 2007 +0100
@@ -61,7 +61,7 @@
     def __init__(self, **kw):
         for key in kw.keys():
             key = key.lower()
-            if not self._ATTRS.has_key(key):
+            if key not in self._ATTRS:
                 raise AttributeError(
                     "Invalid HTML attribute %r for tag <%s>" % (
                         key, self.tagname()))
@@ -78,7 +78,7 @@
         if _SORT_ATTRS: attrs.sort()
         for key, val in attrs:
             key = key.lower()
-            if self._BOOL_ATTRS.has_key(key):
+            if key in self._BOOL_ATTRS:
                 if val: result.append(key)
             else:
                 result.append(u'%s="%s"' % (key, wikiutil.escape(val, 1)))
--- a/MoinMoin/wikiutil.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/MoinMoin/wikiutil.py	Sat Mar 10 22:01:07 2007 +0100
@@ -632,7 +632,7 @@
     """
     _interwiki_list = load_wikimap(request)
     wikiname, pagename, linktext = split_wiki(wikiurl)
-    if _interwiki_list.has_key(wikiname):
+    if wikiname in _interwiki_list:
         return (wikiname, _interwiki_list[wikiname], pagename, False)
     else:
         return (wikiname, request.getScriptname(), "/InterWiki", True)
@@ -912,7 +912,7 @@
             if value[0] == '"' and value[-1] == '"': # remove quotes
                 value = value[1:-1]
             self.params[key.lower()] = value
-        if self.params.has_key('charset'):
+        if 'charset' in self.params:
             self.charset = self.params['charset'].lower()
         self.sanitize()
 
@@ -1367,7 +1367,7 @@
 
             parameter_list.append(value)
             if match.group("name"):
-                if not self.param_dict.has_key(match.group("name")):
+                if match.group("name") not in self.param_dict:
                     raise ValueError, "Unknown parameter name '%s'" % match.group("name")
                 nr = self.param_dict[match.group("name")]
                 if check_list[nr]:
@@ -1532,7 +1532,7 @@
     """
     if formatter is None:
         formatter = request.html_formatter
-    if kw.has_key('css_class'):
+    if 'css_class' in kw:
         css_class = kw['css_class']
         del kw['css_class'] # one time is enough
     else:
--- a/contrib/auth_externalcookie/wikiconfig.py	Sat Mar 10 20:54:09 2007 +0100
+++ b/contrib/auth_externalcookie/wikiconfig.py	Sat Mar 10 22:01:07 2007 +0100
@@ -20,7 +20,7 @@
         except Cookie.CookieError:
             # ignore invalid cookies
             cookie = None
-        if cookie and cookie.has_key(cookiename):
+        if cookie and cookiename in cookie:
             import urllib
             cookievalue = cookie[cookiename].value
             # +++ now we decode and parse the cookie value - edit this to fit your needs.