[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser - BrowserRequest.py:1.1.4.14 BrowserResponse.py:1.1.4.7

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 15:34:56 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser
In directory cvs.zope.org:/tmp/cvs-serv5490/lib/python/Zope/Publisher/Browser

Modified Files:
      Tag: Zope-3x-branch
	BrowserRequest.py BrowserResponse.py 
Log Message:
Implemented 

http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/IContainerPythonification

Along the way:

- Converted most uses of has_key to use in.

- Fixed a bug in Interface names and namesAndDescriptions methods 
  that caused base class attributes to be missed.



=== Zope3/lib/python/Zope/Publisher/Browser/BrowserRequest.py 1.1.4.13 => 1.1.4.14 ===
                         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)
@@ -217,7 +217,7 @@
                        mapping_object = form
 
                     # 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
@@ -300,7 +300,7 @@
                     mapping_object = form
     
                     #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 isinstance(found, ListType):
@@ -314,7 +314,7 @@
             #insert defaults into form dictionary
             if defaults:
                 for keys, values in defaults.items():
-                    if not form.has_key(keys):
+                    if not (keys in form):
                         # if the form does not have the key,
                         # set the default
                         form[keys]=values
@@ -380,7 +380,7 @@
                       attr, new = ":".join(attr[:-1]), attr[-1]
                    attr = new
 
-                   if form.has_key(k):
+                   if k in form:
                       # If the form has the split key get its value
                       item = form[k]
                       if isinstance(item, record):
@@ -401,7 +401,7 @@
                                setattr(x, attr, value)          
                    else:
                       # the form does not have the split 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]  
@@ -557,11 +557,9 @@
 # add class copied from Zope2
 class record:
 
-    # Allow access to record methods and values from DTML
-    __allow_access_to_unprotected_subobjects__=1
-
     def __getattr__(self, key, default=None):
-        if key in ('get', 'keys', 'items', 'values', 'copy', 'has_key'):
+        if key in ('get', 'keys', 'items', 'values', 'copy',
+                   'has_key', '__contains__'):
             return getattr(self.__dict__, key)
         raise AttributeError, key
 


=== Zope3/lib/python/Zope/Publisher/Browser/BrowserResponse.py 1.1.4.6 => 1.1.4.7 ===
         body = str(body)
 
-        if not self._headers.has_key('content-type'):
+        if not ('content-type' in self._headers):
             c = (self.__isHTML(body) and 'text/html' or 'text/plain')
             self.setHeader('content-type', c)