SVN: Zope/branches/2.13/src/ replace has_key with in operator

Nikolay Kim <[email protected]>
Newsgroups gmane.comp.web.zope.cvs
Message-ID <20110712192147.3F70F941ED__38032.8978099444$1310498525$gmane$org@cvs.zope.org>
Log message for revision 122161:
  replace has_key with in operator

Changed:
  U   Zope/branches/2.13/src/App/ApplicationManager.py
  U   Zope/branches/2.13/src/App/ProductContext.py
  U   Zope/branches/2.13/src/App/ProductRegistry.py
  U   Zope/branches/2.13/src/App/special_dtml.py
  U   Zope/branches/2.13/src/OFS/Image.py
  U   Zope/branches/2.13/src/OFS/ObjectManager.py
  U   Zope/branches/2.13/src/OFS/PropertyManager.py
  U   Zope/branches/2.13/src/OFS/PropertySheets.py
  U   Zope/branches/2.13/src/Products/Five/browser/decode.py
  U   Zope/branches/2.13/src/Products/PageTemplates/PageTemplateFile.py
  U   Zope/branches/2.13/src/Products/PageTemplates/ZopePageTemplate.py
  U   Zope/branches/2.13/src/Products/SiteAccess/VirtualHostMonster.py
  U   Zope/branches/2.13/src/Shared/DC/Scripts/Bindings.py
  U   Zope/branches/2.13/src/ZPublisher/BaseRequest.py
  U   Zope/branches/2.13/src/ZPublisher/BaseResponse.py
  U   Zope/branches/2.13/src/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.13/src/ZPublisher/HTTPResponse.py
  U   Zope/branches/2.13/src/ZPublisher/Publish.py
  U   Zope/branches/2.13/src/ZTUtils/Zope.py

-=-
Modified: Zope/branches/2.13/src/App/ApplicationManager.py
===================================================================
--- Zope/branches/2.13/src/App/ApplicationManager.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/App/ApplicationManager.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -353,7 +353,7 @@
             return '%.1fM' % (s/1048576.0)
         return '%.1fK' % (s/1024.0)
 
-    if os.environ.has_key('ZMANAGED'):
+    if 'ZMANAGED' in os.environ:
         manage_restartable = 1
         @requestmethod('POST')
         def manage_restart(self, URL1, REQUEST=None):

Modified: Zope/branches/2.13/src/App/ProductContext.py
===================================================================
--- Zope/branches/2.13/src/App/ProductContext.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/App/ProductContext.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -151,7 +151,7 @@
             else:
                 name=method.__name__
                 aliased = 0
-            if not OM.__dict__.has_key(name):
+            if name not in OM.__dict__:
                 setattr(OM, name, method)
                 setattr(OM, name+'__roles__', pr)
                 if aliased:
@@ -213,7 +213,7 @@
                 name, method = method
             else:
                 name=os.path.split(method.__name__)[-1]
-            if not productObject.__dict__.has_key(name):
+            if name not in productObject.__dict__:
                 m[name]=method
                 m[name+'__roles__']=pr
 

Modified: Zope/branches/2.13/src/App/ProductRegistry.py
===================================================================
--- Zope/branches/2.13/src/App/ProductRegistry.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/App/ProductRegistry.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -32,7 +32,7 @@
         r=[]
         pid=product.id
         for mt in self._getProductRegistryMetaTypes():
-            if mt.has_key('product'):
+            if 'product' in mt:
                 if mt['product']==pid and (
                     meta_type is None or meta_type==mt['name']):
                     continue
@@ -52,7 +52,7 @@
 
         for mt in meta_types:
             if mt['name']==meta_type:
-                if not mt.has_key('product'): mt['product']=pid
+                if 'product' not in mt: mt['product']=pid
                 if mt['product'] != pid:
                     raise ValueError, (
                         'The type <em>%s</em> is already defined.' % meta_type)

Modified: Zope/branches/2.13/src/App/special_dtml.py
===================================================================
--- Zope/branches/2.13/src/App/special_dtml.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/App/special_dtml.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -44,7 +44,7 @@
         elif type(_prefix) is not type(''):
             _prefix = Common.package_home(_prefix)
         args=(self, os.path.join(_prefix, name + '.dtml'))
-        if not kw.has_key('__name__'):
+        if '__name__' not in kw:
             kw['__name__'] = os.path.split(name)[-1]
         apply(ClassicHTMLFile.inheritedAttribute('__init__'), args, kw)
 

Modified: Zope/branches/2.13/src/OFS/Image.py
===================================================================
--- Zope/branches/2.13/src/OFS/Image.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/OFS/Image.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -504,7 +504,7 @@
 
     def _get_content_type(self, file, body, id, content_type=None):
         headers=getattr(file, 'headers', None)
-        if headers and headers.has_key('content-type'):
+        if headers and 'content-type' in headers:
             content_type=headers['content-type']
         else:
             if not isinstance(body, str): body=body.data

Modified: Zope/branches/2.13/src/OFS/ObjectManager.py
===================================================================
--- Zope/branches/2.13/src/OFS/ObjectManager.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/OFS/ObjectManager.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -273,7 +273,7 @@
         else:
             all = self.all_meta_types
         for meta_type in all:
-            if meta_type.has_key('permission'):
+            if 'permission' in meta_type:
                 if sm.checkPermission(meta_type['permission'], self):
                     meta_types.append(meta_type)
             else:
@@ -476,7 +476,6 @@
         seen={}
         vals=[]
         relativePhysicalPath = ()
-        have=seen.has_key
         x=0
         while x < 100:
             if not hasattr(obj,'_getOb'): break
@@ -486,7 +485,7 @@
                     try:
                         id=i['id']
                         physicalPath = relativePhysicalPath + (id,)
-                        if (not have(physicalPath)) and (i['meta_type'] in t):
+                        if (physicalPath not in seen) and (i['meta_type'] in t):
                             vals.append(get(id))
                             seen[physicalPath]=1
                     except: pass

Modified: Zope/branches/2.13/src/OFS/PropertyManager.py
===================================================================
--- Zope/branches/2.13/src/OFS/PropertyManager.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/OFS/PropertyManager.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -204,7 +204,7 @@
             raise BadRequest, 'The property %s does not exist' % escape(id)
         if type(value)==type(''):
             proptype=self.getPropertyType(id) or 'string'
-            if type_converters.has_key(proptype):
+            if proptype in type_converters:
                 value=type_converters[proptype](value)
         self._setPropValue(id, value)
 
@@ -281,7 +281,7 @@
 
         Sets a new property with the given id, type, and value.
         """
-        if type_converters.has_key(type):
+        if type in type_converters:
             value=type_converters[type](value)
         self._setProperty(id.strip(), value, type)
         if REQUEST is not None:

Modified: Zope/branches/2.13/src/OFS/PropertySheets.py
===================================================================
--- Zope/branches/2.13/src/OFS/PropertySheets.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/OFS/PropertySheets.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -199,7 +199,7 @@
         pself=self.p_self()
         self=self.v_self()
         if hasattr(aq_base(self),id):
-            if not (id=='title' and not self.__dict__.has_key(id)):
+            if not (id=='title' and not id in self.__dict__):
                 raise BadRequest, (
                     'Invalid property id, <em>%s</em>. It is in use.' %
                         escape(id))
@@ -233,7 +233,7 @@
             raise BadRequest, '%s cannot be changed.' % escape(id)
         if type(value)==type(''):
             proptype=propinfo.get('type', 'string')
-            if type_converters.has_key(proptype):
+            if proptype in type_converters:
                 value=type_converters[proptype](value)
         if meta is not None:
             props=[]
@@ -361,7 +361,7 @@
         # property name and value for the requested property.
         xml_id=self.xml_namespace()
         propdict=self._propdict()
-        if not propdict.has_key(name):
+        if name not in propdict:
             if xml_id:
                 prop='<n:%s xmlns:n="%s"/>\n' % (name, xml_id)
             else:
@@ -419,7 +419,7 @@
     def manage_addProperty(self, id, value, type, REQUEST=None):
         """Add a new property via the web. Sets a new property with
         the given id, type, and value."""
-        if type_converters.has_key(type):
+        if type in type_converters:
             value=type_converters[type](value)
         self._setProperty(id, value, type)
         if REQUEST is not None:

Modified: Zope/branches/2.13/src/Products/Five/browser/decode.py
===================================================================
--- Zope/branches/2.13/src/Products/Five/browser/decode.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/Products/Five/browser/decode.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -15,7 +15,7 @@
     encoding.
 """
 
-from zope.publisher.browser import isCGI_NAME
+from ZPublisher.HTTPRequest import isCGI_NAMEs
 from zope.i18n.interfaces import IUserPreferredCharsets
 
 # taken and adapted from zope.publisher.browser.BrowserRequest
@@ -62,7 +62,7 @@
             charsets = envadapter.getPreferredCharsets() or ['utf-8']
     
     for name, value in request.form.items():
-        if not (isCGI_NAME(name) or name.startswith('HTTP_')):
+        if not (name in isCGI_NAMEs or name.startswith('HTTP_')):
             request.form[name] = processInputValue(value, charsets)
 
 def setPageEncoding(request):

Modified: Zope/branches/2.13/src/Products/PageTemplates/PageTemplateFile.py
===================================================================
--- Zope/branches/2.13/src/Products/PageTemplates/PageTemplateFile.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/Products/PageTemplates/PageTemplateFile.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -109,7 +109,7 @@
     def _exec(self, bound_names, args, kw):
         """Call a Page Template"""
         self._cook_check()
-        if not kw.has_key('args'):
+        if 'args' not in kw:
             kw['args'] = args
         bound_names['options'] = kw
 

Modified: Zope/branches/2.13/src/Products/PageTemplates/ZopePageTemplate.py
===================================================================
--- Zope/branches/2.13/src/Products/PageTemplates/ZopePageTemplate.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/Products/PageTemplates/ZopePageTemplate.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -303,7 +303,7 @@
 
     def _exec(self, bound_names, args, kw):
         """Call a Page Template"""
-        if not kw.has_key('args'):
+        if 'args' not in kw:
             kw['args'] = args
         bound_names['options'] = kw
 

Modified: Zope/branches/2.13/src/Products/SiteAccess/VirtualHostMonster.py
===================================================================
--- Zope/branches/2.13/src/Products/SiteAccess/VirtualHostMonster.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/Products/SiteAccess/VirtualHostMonster.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -97,7 +97,7 @@
                 else:
                     host_map = fixed_map
                 hostname, port = (host.split( ':', 1) + [None])[:2]
-                if not host_map.has_key(hostname):
+                if hostname not in host_map:
                     host_map[hostname] = {}
                 host_map[hostname][port] = pp
             except 'LineError', msg:

Modified: Zope/branches/2.13/src/Shared/DC/Scripts/Bindings.py
===================================================================
--- Zope/branches/2.13/src/Shared/DC/Scripts/Bindings.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/Shared/DC/Scripts/Bindings.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -55,7 +55,7 @@
         asgns = {}
         _isLegalName = self._isLegalName
         for name, expr in self._exprs:
-            if mapping.has_key(name):
+            if name in mapping:
                 assigned_name = string.strip(mapping[name])
                 if not assigned_name:
                     continue
@@ -71,7 +71,7 @@
         return 0
 
     def isNameAssigned(self, name):
-        return self._asgns.has_key(name)
+        return name in self._asgns
 
     def getAssignedName(self, name, default=_marker):
         val = self._asgns.get(name, default)
@@ -89,7 +89,7 @@
         rval = []
         asgns = self._asgns
         for name, expr in self._exprs:
-            if asgns.has_key(name):
+            if name in asgns:
                 assigned_name = asgns[name]
                 rval.append(assigned_name)
         return rval
@@ -114,7 +114,7 @@
         assigned_names = []
         asgns = self._asgns
         for name, expr in self._exprs:
-            if asgns.has_key(name):
+            if name in asgns:
                 assigned_name = asgns[name]
                 assigned_names.append(assigned_name)
                 exprtext.append('"%s":%s,' % (assigned_name, expr))
@@ -133,7 +133,7 @@
             passedLastBoundArg = 1
             for name, expr in self._exprs:
                 # Provide a value for the available exprs.
-                if asgns.has_key(name):
+                if name in asgns:
                     assigned_name = asgns[name]
                     if assigned_name == argName:
                         # The value for this argument will be filled in.

Modified: Zope/branches/2.13/src/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/BaseRequest.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/ZPublisher/BaseRequest.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -669,7 +669,7 @@
         if auth: name,password = auth
         elif roles is None: return ''
         else: return None
-    elif request.environ.has_key('REMOTE_USER'):
+    elif 'REMOTE_USER' in request.environ:
         name=request.environ['REMOTE_USER']
         password=None
     else:
@@ -693,11 +693,11 @@
         if roles is UNSPECIFIED_ROLES: roles=keys()
         g=[]
         for role in roles:
-            if groups.has_key(role): g.append(groups[role])
+            if role in groups: g.append(groups[role])
         groups=g
 
     for d in groups:
-        if d.has_key(name) and (d[name]==password or password is None):
+        if name in d and (d[name]==password or password is None):
             return name
 
     if keys is None:

Modified: Zope/branches/2.13/src/ZPublisher/BaseResponse.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/BaseResponse.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/ZPublisher/BaseResponse.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -69,7 +69,7 @@
         cookie in the Response object.
         '''
         cookies = self.cookies
-        if cookies.has_key(name):
+        if name in cookies:
             cookie = cookies[name]
         else:
             cookie = cookies[name] = {}

Modified: Zope/branches/2.13/src/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/HTTPRequest.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/ZPublisher/HTTPRequest.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -59,7 +59,7 @@
 # This may get overwritten during configuration
 default_encoding = 'iso-8859-15'
 
-isCGI_NAME = {
+isCGI_NAMEs = {
         'SERVER_SOFTWARE' : 1,
         'SERVER_NAME' : 1,
         'GATEWAY_INTERFACE' : 1,
@@ -78,10 +78,12 @@
         'CONTENT_TYPE' : 1,
         'CONTENT_LENGTH' : 1,
         'SERVER_URL': 1,
-        }.has_key
+        }
 
-hide_key = {'HTTP_AUTHORIZATION':1, 'HTTP_CGI_AUTHORIZATION': 1}.has_key
+isCGI_NAME = isCGI_NAMEs.has_key
 
+hide_key = {'HTTP_AUTHORIZATION':1, 'HTTP_CGI_AUTHORIZATION': 1}
+
 default_port = {'http': '80', 'https': '443'}
 
 tainting_env = str(os.environ.get('ZOPE_DTML_REQUEST_AUTOQUOTE', '')).lower()
@@ -321,14 +323,13 @@
         if not clean:
             environ = sane_environment(environ)
 
-        if environ.has_key('HTTP_AUTHORIZATION'):
+        if 'HTTP_AUTHORIZATION' in environ:
             self._auth = environ['HTTP_AUTHORIZATION']
             response._auth = 1
             del environ['HTTP_AUTHORIZATION']
 
         self.stdin = stdin
         self.environ = environ
-        have_env = environ.has_key
         get_env = environ.get
         self.response = response
         other = self.other = {'RESPONSE': response}
@@ -341,9 +342,9 @@
         # We don't set up the locale initially but just on first access
         self._locale = _marker
 
-        if environ.has_key('REMOTE_ADDR'):
+        if 'REMOTE_ADDR' in environ:
             self._client_addr = environ['REMOTE_ADDR']
-            if (environ.has_key('HTTP_X_FORWARDED_FOR') and
+            if ('HTTP_X_FORWARDED_FOR' in environ and
                 self._client_addr in trusted_proxies):
                 # REMOTE_ADDR is one of our trusted local proxies.
                 # Not really very remote at all.  The proxy can tell us the
@@ -382,16 +383,16 @@
         if server_url is not None:
             other['SERVER_URL'] = server_url = server_url.strip()
         else:
-            if have_env('HTTPS') and (
+            if 'HTTPS' in environ and (
                 environ['HTTPS'] == "on" or environ['HTTPS'] == "ON"):
                 protocol = 'https'
-            elif (have_env('SERVER_PORT_SECURE') and
+            elif ('SERVER_PORT_SECURE' in environ and
                 environ['SERVER_PORT_SECURE'] == "1"):
                 protocol = 'https'
             else:
                 protocol = 'http'
 
-            if have_env('HTTP_HOST'):
+            if 'HTTP_HOST' in environ:
                 host = environ['HTTP_HOST'].strip()
                 hostname, port = splitport(host)
 
@@ -401,7 +402,7 @@
                 # the commented code here in case we care enough to come
                 # back and do anything with it later.
                 #
-                # if port is None and environ.has_key('SERVER_PORT'):
+                # if port is None and 'SERVER_PORT' in environ:
                 #     s_port = environ['SERVER_PORT']
                 #     if s_port not in ('80', '443'):
                 #         port = s_port
@@ -486,17 +487,17 @@
         # If 'QUERY_STRING' is not present in environ
         # FieldStorage will try to get it from sys.argv[1]
         # which is not what we need.
-        if not environ.has_key('QUERY_STRING'):
+        if 'QUERY_STRING' not in environ:
             environ['QUERY_STRING'] = ''
 
         meth = None
         fs = ZopeFieldStorage(fp=fp,environ=environ,keep_blank_values=1)
         if not hasattr(fs,'list') or fs.list is None:
-            if environ.has_key('HTTP_SOAPACTION'):
+            if 'HTTP_SOAPACTION' in environ:
                 # Stash XML request for interpretation by a SOAP-aware view
                 other['SOAPXML'] = fs.value
             # Hm, maybe it's an XML-RPC
-            elif (fs.headers.has_key('content-type') and
+            elif ('content-type' in fs.headers and
                 'text/xml' in fs.headers['content-type'] and
                 method == 'POST'):
                 # Ye haaa, XML-RPC!
@@ -513,7 +514,7 @@
             fslist = fs.list
             tuple_items = {}
             lt = type([])
-            CGI_name = isCGI_NAME
+            CGI_name = isCGI_NAMEs
             defaults = {}
             tainteddefaults = {}
             converter = None
@@ -605,7 +606,7 @@
                             l = -1
 
                 # Filter out special names from form:
-                if CGI_name(key) or key[:5] == 'HTTP_':
+                if key in CGI_name or key[:5] == 'HTTP_':
                     continue
 
                 # If the key is tainted, mark it so as well.
@@ -670,13 +671,13 @@
 
                         except:
                             if (not item and not (flags & DEFAULT) and
-                                defaults.has_key(key)):
+                                key in defaults):
                                 item = defaults[key]
                                 if flags & RECORD:
                                     item = getattr(item,attr)
                                 if flags & RECORDS:
                                     item = getattr(item[-1], attr)
-                                if tainteddefaults.has_key(tainted_key):
+                                if tainted_key in tainteddefaults:
                                     tainted = tainteddefaults[tainted_key]
                                     if flags & RECORD:
                                         tainted = getattr(tainted, attr)
@@ -703,7 +704,7 @@
                         tainted_mapping = taintedform
 
                     #Insert in dictionary
-                    if mapping_object.has_key(key):
+                    if key in mapping_object:
                         if flags & RECORDS:
                             #Get the list and the last record
                             #in the list. reclist is mutable.
@@ -712,7 +713,7 @@
 
                             if tainted:
                                 # Store a tainted copy as well
-                                if not tainted_mapping.has_key(tainted_key):
+                                if tainted_key not in tainted_mapping:
                                     tainted_mapping[tainted_key] = deepcopy(
                                         reclist)
                                 treclist = tainted_mapping[tainted_key]
@@ -731,7 +732,7 @@
                                         setattr(newrec, attr, tainted)
                                         treclist.append(newrec)
 
-                            elif tainted_mapping.has_key(tainted_key):
+                            elif tainted_key in tainted_mapping:
                                 # If we already put a tainted value into this
                                 # recordset, we need to make sure the whole
                                 # recordset is built.
@@ -791,7 +792,7 @@
 
                             # Store a tainted copy as well if necessary
                             if tainted:
-                                if not tainted_mapping.has_key(tainted_key):
+                                if tainted_key not in tainted_mapping:
                                     tainted_mapping[tainted_key] = deepcopy(
                                         mapping_object[key])
                                 b = tainted_mapping[tainted_key]
@@ -802,7 +803,7 @@
                                 else:
                                     setattr(b, attr, tainted)
 
-                            elif tainted_mapping.has_key(tainted_key):
+                            elif tainted_key in tainted_mapping:
                                 # If we already put a tainted value into this
                                 # record, we need to make sure the whole record
                                 # is built.
@@ -820,7 +821,7 @@
 
                             if tainted:
                                 # Store a tainted version if necessary
-                                if not tainted_mapping.has_key(tainted_key):
+                                if tainted_key not in tainted_mapping:
                                     copied = deepcopy(found)
                                     if isinstance(copied, lt):
                                         tainted_mapping[tainted_key] = copied
@@ -828,7 +829,7 @@
                                         tainted_mapping[tainted_key] = [copied]
                                 tainted_mapping[tainted_key].append(tainted)
 
-                            elif tainted_mapping.has_key(tainted_key):
+                            elif tainted_key in tainted_mapping:
                                 # We may already have encountered a tainted
                                 # value for this key, and the tainted_mapping
                                 # needs to hold all the values.
@@ -899,13 +900,13 @@
                         tainted = item
 
                     #Insert in dictionary
-                    if mapping_object.has_key(key):
+                    if key in mapping_object:
                         # it is not a record or list of records
                         found = mapping_object[key]
 
                         if tainted:
                             # Store a tainted version if necessary
-                            if not taintedform.has_key(tainted_key):
+                            if tainted_key not in taintedform:
                                 copied = deepcopy(found)
                                 if isinstance(copied, lt):
                                     taintedform[tainted_key] = copied
@@ -916,7 +917,7 @@
                                     taintedform[tainted_key]]
                             taintedform[tainted_key].append(tainted)
 
-                        elif taintedform.has_key(tainted_key):
+                        elif tainted_key in taintedform:
                             # We may already have encountered a tainted value
                             # for this key, and the taintedform needs to hold
                             # all the values.
@@ -943,12 +944,12 @@
                     if '<' in key:
                         tainted_key = TaintedString(key)
 
-                    if not form.has_key(key):
+                    if key not in form:
                         # if the form does not have the key,
                         # set the default
                         form[key] = value
 
-                        if tainteddefaults.has_key(tainted_key):
+                        if tainted_key in tainteddefaults:
                             taintedform[tainted_key] = \
                                 tainteddefaults[tainted_key]
                     else:
@@ -960,13 +961,13 @@
                             r = form[key]
 
                             # First deal with tainted defaults.
-                            if taintedform.has_key(tainted_key):
+                            if tainted_key in taintedform:
                                 tainted = taintedform[tainted_key]
                                 for k, v in tdefault.__dict__.items():
                                     if not hasattr(tainted, k):
                                         setattr(tainted, k, v)
 
-                            elif tainteddefaults.has_key(tainted_key):
+                            elif tainted_key in tainteddefaults:
                                 # Find out if any of the tainted default
                                 # attributes needs to be copied over.
                                 missesdefault = 0
@@ -997,7 +998,7 @@
                                 l = [l]
 
                             # First deal with tainted copies
-                            if taintedform.has_key(tainted_key):
+                            if tainted_key in taintedform:
                                 tainted = taintedform[tainted_key]
                                 if not isinstance(tainted, lt):
                                     tainted = [tainted]
@@ -1012,7 +1013,7 @@
                                             tainted.append(defitem)
                                 taintedform[tainted_key] = tainted
 
-                            elif tainteddefaults.has_key(tainted_key):
+                            elif tainted_key in tainteddefaults:
                                 missesdefault = 0
                                 for defitem in tdefault:
                                     if isinstance(defitem, record):
@@ -1089,7 +1090,7 @@
                         a = a.split( ":")
                         a,new = ':'.join(a[:-1]), a[-1]
                     attr = new
-                    if form.has_key(k):
+                    if k in form:
                         # If the form has the split key get its value
                         tainted_split_key = k
                         if '<' in k:
@@ -1113,7 +1114,7 @@
                                     setattr(x,attr,value)
 
                         # Do the same for the tainted counterpart
-                        if taintedform.has_key(tainted_split_key):
+                        if tainted_split_key in taintedform:
                             tainted = taintedform[tainted_split_key]
                             if isinstance(item, record):
                                 seq = tuple(getattr(tainted, attr))
@@ -1129,19 +1130,19 @@
                         tainted_key = key
                         if '<' in key:
                             tainted_key = TaintedString(key)
-                        if form.has_key(key):
+                        if key in form:
                             # if it has the original key, get the item
                             # convert it to a tuple
                             item = form[key]
                             item = tuple(form[key])
                             form[key] = item
 
-                        if taintedform.has_key(tainted_key):
+                        if tainted_key in taintedform:
                             tainted = tuple(taintedform[tainted_key])
                             taintedform[tainted_key] = tainted
 
         if meth:
-            if environ.has_key('PATH_INFO'):
+            if 'PATH_INFO' in environ:
                 path = environ['PATH_INFO']
                 while path[-1:] == '/':
                     path = path[:-1]
@@ -1253,7 +1254,7 @@
 
         """ #"
         other = self.other
-        if other.has_key(key):
+        if key in other:
             if key == 'REQUEST':
                 return self
             return other[key]
@@ -1271,15 +1272,15 @@
                 else:
                     path = [other['SERVER_URL']] + path[:n]
                 URL = '/'.join(path)
-                if other.has_key('PUBLISHED'):
+                if 'PUBLISHED' in other:
                     # Don't cache URLs until publishing traversal is done.
                     other[key] = URL
                     self._urls = self._urls + (key,)
                 return URL
 
-        if isCGI_NAME(key) or key[:5] == 'HTTP_':
+        if key in isCGI_NAMEs or key[:5] == 'HTTP_':
             environ = self.environ
-            if environ.has_key(key) and (not hide_key(key)):
+            if key in environ and (key not in hide_key):
                 return environ[key]
             return ''
 
@@ -1305,7 +1306,7 @@
                 else:
                     v.insert(0, other['SERVER_URL'])
                 URL = '/'.join(v)
-                if other.has_key('PUBLISHED'):
+                if 'PUBLISHED' in other:
                     # Don't cache URLs until publishing traversal is done.
                     other[key] = URL
                     self._urls = self._urls + (key,)
@@ -1406,7 +1407,7 @@
         keys.update(self._lazies)
 
         for key in self.environ.keys():
-            if (isCGI_NAME(key) or key[:5] == 'HTTP_') and (not hide_key(key)):
+            if (key in isCGI_NAMEs or key[:5] == 'HTTP_') and (key not in hide_key):
                 keys[key] = 1
 
         # Cache URLN and BASEN in self.other.
@@ -1470,7 +1471,7 @@
 
         result = result + "</table><h3>environ</h3><table>"
         for k,v in self.environ.items():
-            if not hide_key(k):
+            if k not in hide_key:
                 result = result + row % (escape(k), escape(repr(v)))
         return result + "</table>"
 
@@ -1509,7 +1510,7 @@
 
         result = result + "\nENVIRON\n\n"
         for k,v in self.environ.items():
-            if not hide_key(k):
+            if k not in hide_key:
                 result = result + row % (k, v)
         return result
 
@@ -1575,7 +1576,7 @@
         while key[:9] == 'REDIRECT_':
             key = key[9:]
         dict[key] = val
-    if dict.has_key('HTTP_CGI_AUTHORIZATION'):
+    if 'HTTP_CGI_AUTHORIZATION' in dict:
         dict['HTTP_AUTHORIZATION'] = dict['HTTP_CGI_AUTHORIZATION']
         try:
             del dict['HTTP_CGI_AUTHORIZATION']
@@ -1661,7 +1662,6 @@
 
     if result is None:
         result = {}
-    already_have = result.has_key
 
     acquire()
     try:
@@ -1694,7 +1694,7 @@
     finally:
         release()
 
-    if not already_have(name):
+    if name not in result:
         result[name] = unquote(value)
 
     return apply(parse_cookie,(text[l:],result))

Modified: Zope/branches/2.13/src/ZPublisher/HTTPResponse.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/HTTPResponse.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/ZPublisher/HTTPResponse.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -220,7 +220,7 @@
         if isinstance(status, str):
             status = status.lower()
 
-        if status_codes.has_key(status):
+        if status in status_codes:
             status = status_codes[status]
         else:
             status = 500
@@ -228,7 +228,7 @@
         self.status = status
 
         if reason is None:
-            if status_reasons.has_key(status):
+            if status in status_reasons:
                 reason = status_reasons[status]
             else:
                 reason = 'Unknown'
@@ -252,7 +252,7 @@
         value = str(value)
 
         cookies = self.cookies
-        if cookies.has_key(name):
+        if name in cookies:
             cookie = cookies[name]
         else:
             cookie = cookies[name] = {}
@@ -273,11 +273,11 @@
         value = str(value)
 
         cookies = self.cookies
-        if cookies.has_key(name):
+        if name in cookies:
             cookie = cookies[name]
         else:
             cookie = cookies[name] = {}
-        if cookie.has_key('value'):
+        if 'value' in cookie:
             cookie['value'] = '%s:%s' % (cookie['value'], value)
         else:
             cookie['value'] = value
@@ -351,7 +351,7 @@
         name = name.lower()
 
         headers = self.headers
-        if headers.has_key(name):
+        if name in headers:
             h = headers[name]
             h = "%s%s%s" % (h, delimiter, value)
         else:

Modified: Zope/branches/2.13/src/ZPublisher/Publish.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/Publish.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/ZPublisher/Publish.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -286,7 +286,7 @@
                     release=_l.release,
                     ):
 
-    if modules.has_key(module_name): return modules[module_name]
+    if module_name in modules: return modules[module_name]
 
     if module_name[-4:]=='.cgi': module_name=module_name[:-4]
 

Modified: Zope/branches/2.13/src/ZTUtils/Zope.py
===================================================================
--- Zope/branches/2.13/src/ZTUtils/Zope.py	2011-07-12 16:03:03 UTC (rev 122160)
+++ Zope/branches/2.13/src/ZTUtils/Zope.py	2011-07-12 19:21:45 UTC (rev 122161)
@@ -297,18 +297,17 @@
             omits = {}
             for name in omit:
                 omits[name] = None
-        omitted = omits.has_key
 
         unq = urllib.unquote
         for i in range(len(qsparts)):
             name = unq(qsparts[i].split('=', 1)[0])
-            if omitted(name):
+            if name in omits:
                 qsparts[i] = ''
             name = name.split(':', 1)[0]
-            if omitted(name):
+            if name in omits:
                 qsparts[i] = ''
             name = name.split('.', 1)[0]
-            if omitted(name):
+            if name in omits:
                 qsparts[i] = ''
 
         qs = '&'.join(filter(None, qsparts))

_______________________________________________
Zope-Checkins maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.