[Zope3-checkins] CVS: Zope3/src/zope/publisher - browser.py:1.1.2.4 http.py:1.1.2.4 maybe_lock.py:1.1.2.2 publish.py:1.1.2.3 vfs.py:1.1.2.3 xmlrpc.py:1.1.2.3

Tim Peters tim.one@comcast.net
Tue, 24 Dec 2002 21:21:45 -0500


Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/publisher

Modified Files:
      Tag: NameGeddon-branch
	browser.py http.py maybe_lock.py publish.py vfs.py xmlrpc.py 
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py.  The
files are fixed-points of that script now.  Fixed a few cases where
code relied on significant trailing whitespace (ouch).


=== Zope3/src/zope/publisher/browser.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/publisher/browser.py:1.1.2.3	Tue Dec 24 07:51:28 2002
+++ Zope3/src/zope/publisher/browser.py	Tue Dec 24 21:21:14 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 __version__='$Revision$'[11:-2]
 
@@ -39,7 +39,7 @@
         else:          l=mo.start(0)
 
     r.append(v[s:])
-        
+
     return '\n'.join(r)
 
 def field2required(v):
@@ -162,8 +162,8 @@
     __implements__ = IBrowserView
 
     def __init__(self, context, request):
-       self.context = context
-       self.request = request
+        self.context = context
+        self.request = request
 
 
 
@@ -218,11 +218,11 @@
     use_redirect = 0 # Set this to 1 in a subclass to redirect GET
                      # requests when the effective and actual URLs differ.
 
-    # _presentation_type is overridden from the BaseRequest 
+    # _presentation_type is overridden from the BaseRequest
     #  to implement IBrowserPresentation
     _presentation_type = IBrowserPresentation
 
-    
+
 
     def __init__(self, body_instream, outstream, environ, response=None):
         self.form = {}
@@ -236,7 +236,7 @@
         return BrowserResponse(outstream)
 
     def _decode(self, text):
-        """Try to decode the text using one of the available charsets.""" 
+        """Try to decode the text using one of the available charsets."""
         if self.charsets is None:
             envadaptor = getAdapter(self, IUserPreferredCharsets)
             self.charsets = envadaptor.getPreferredCharsets()
@@ -276,7 +276,7 @@
             # process all entries in the field storage (form)
             for item in fslist:
 
-                # Check whether this field is a file upload object 
+                # Check whether this field is a file upload object
                 key = item.name
                 if (hasattr(item, 'file') and hasattr(item, 'filename')
                     and hasattr(item,'headers')):
@@ -290,7 +290,7 @@
                         item = item.value
 
                 flags = 0
-                
+
                 # Loop through the different types and set
                 # the appropriate flags
                 # Syntax: var_name:type_name
@@ -299,7 +299,7 @@
                 # We'll do the search in two steps.  First, we'll
                 # do a string search, and then we'll check it with
                 # a re search.
-                
+
                 # Get the location of the name type splitter
                 loc = key.rfind(':')
                 if loc >= 0:
@@ -312,8 +312,8 @@
                         key = key[:loc]
                         # find the right type converter
                         c = get_converter(type_name, None)
-                        
-                        if c is not None: 
+
+                        if c is not None:
                             converter = c
                             flags=flags|CONVERTED
                         elif type_name == 'list':
@@ -339,7 +339,7 @@
                             flags=flags|RECORDS
                         elif type_name == 'ignore_empty':
                             if not item: flags=flags|EMPTY
-    
+
                         loc = key.rfind(':')
                         if loc < 0:
                             break
@@ -353,7 +353,7 @@
                 # Filter out special names from form:
                 if CGI_name(key) or key.startswith('HTTP_'):
                     continue
-                
+
                 # Make it unicode
                 key = self._decode(key)
                 if type(item) == StringType:
@@ -368,7 +368,7 @@
                     if flags & REC:
                         key = key.split(".")
                         key, attr = ".".join(key[:-1]), key[-1]
-                       
+
                     # defer conversion
                     if flags & CONVERTED:
                         try:
@@ -384,13 +384,13 @@
                                     item = item[0]
                                     item=getattr(item,attr)
                             else:
-                                raise                            
-                         
+                                raise
+
                     # Determine which dictionary to use
                     if flags & DEFAULT:
-                       mapping_object = defaults
+                        mapping_object = defaults
                     else:
-                       mapping_object = form
+                        mapping_object = form
 
                     # Insert in dictionary
                     if key in mapping_object:
@@ -430,19 +430,19 @@
                         elif flags&RECORD:
                             b=mapping_object[key]
                             if flags&SEQUENCE:
-                               item=[item]
-                               if not hasattr(b,attr):
-                                   # if it does not have the
-                                   # attribute, set it
-                                   setattr(b,attr,item)
-                               else:
-                                   # it has the attribute so
-                                   # append the item to it
-                                   setattr(b,attr,getattr(b,attr)+item)
+                                item=[item]
+                                if not hasattr(b,attr):
+                                    # if it does not have the
+                                    # attribute, set it
+                                    setattr(b,attr,item)
+                                else:
+                                    # it has the attribute so
+                                    # append the item to it
+                                    setattr(b,attr,getattr(b,attr)+item)
                             else:
-                               # it is not a sequence so
-                               # set the attribute
-                               setattr(b,attr,item)        
+                                # it is not a sequence so
+                                # set the attribute
+                                setattr(b,attr,item)
                         else:
                             # it is not a record or list of records
                             found=mapping_object[key]
@@ -474,7 +474,7 @@
                 else:
                     # This branch is for case when no type was specified.
                     mapping_object = form
-    
+
                     #Insert in dictionary
                     if key in mapping_object:
                         # it is not a record or list of records
@@ -504,10 +504,10 @@
                                 # loop through the attributes and values
                                 # in the default dictionary
                                 if not hasattr(r, k):
-                                   # if the form dictionary doesn't have
-                                   # the attribute, set it to the default
-                                   setattr(r,k,v)
-                                   form[keys] = r    
+                                    # if the form dictionary doesn't have
+                                    # the attribute, set it to the default
+                                    setattr(r,k,v)
+                                    form[keys] = r
 
                         elif isinstance(values, list):
                             # the key is mapped to a list
@@ -517,20 +517,20 @@
                                 if isinstance(val, record):
                                     # if the val is a record
                                     for k, v in val.__dict__.items():
-                                           
+
                                         # loop through each
                                         # attribute and value in
                                         # the record
-                                           
+
                                         for y in lst:
-                                               
+
                                             # loop through each
                                             # record in the form
                                             # list if it doesn't
                                             # have the attributes
                                             # in the default
                                             # dictionary, set them
-                                              
+
                                             if not hasattr(y, k):
                                                 setattr(y, k, v)
                                 else:
@@ -542,7 +542,7 @@
                             # The form has the key, the key is not mapped
                             # to a record or sequence so do nothing
                             pass
-                                
+
             # Convert to tuples
             if tuple_items:
                 for key in tuple_items.keys():
@@ -574,13 +574,13 @@
                                     # If the record has the attribute
                                     # convert it to a tuple and set it
                                     value = tuple(getattr(x, attr))
-                                    setattr(x, attr, value)          
+                                    setattr(x, attr, value)
                     else:
-                        # the form does not have the split key 
+                        # the form does not have the split key
                         if key in form:
                             # if it has the original key, get the item
                             # convert it to a tuple
-                            item = form[key]  
+                            item = form[key]
                             item = tuple(form[key])
                             form[key] = item
 
@@ -603,7 +603,7 @@
         elif method in DEFAULTABLE_METHODS:
             # We need to check for default documents
             publication = self.publication
-            
+
             nsteps = 0
             ob, add_steps = publication.getDefaultTraversal(self, ob)
             while add_steps:
@@ -647,7 +647,7 @@
 
         result = self._cookies.get(key, self)
         if result is not self: return result
-        
+
         result = self._environ.get(key, self)
         if result is not self: return result
 
@@ -684,7 +684,7 @@
 class RedirectingBrowserRequest(BrowserRequest):
     """Browser requests that redirect when the actual and effective URLs differ
     """
-    
+
     use_redirect = 1
 
 class TestRequest(BrowserRequest):
@@ -710,7 +710,7 @@
             outstream = StringIO()
 
         super(TestRequest, self).__init__(body_instream, outstream, _testEnv)
-    
+
 # add class copied from Zope2
 class record:
 
@@ -722,18 +722,18 @@
 
     def __getitem__(self, key):
         return self.__dict__[key]
-            
+
     def __str__(self):
         L1 = self.__dict__.items()
         L1.sort()
-        return ", ".join(map(lambda item: "%s: %s" % item, L1)) 
+        return ", ".join(map(lambda item: "%s: %s" % item, L1))
 
     def __repr__(self):
         L1 = self.__dict__.items()
         L1.sort()
         return ', '.join(
             map(lambda item: "%s: %s" % (item[0], repr(item[1])), L1))
-    
+
 
 
 import cgi
@@ -743,22 +743,22 @@
 
 isCGI_NAME = {
     # These fields are placed in request.environ instead of request.form.
-    'SERVER_SOFTWARE' : 1, 
-    'SERVER_NAME' : 1, 
-    'GATEWAY_INTERFACE' : 1, 
-    'SERVER_PROTOCOL' : 1, 
-    'SERVER_PORT' : 1, 
-    'REQUEST_METHOD' : 1, 
-    'PATH_INFO' : 1, 
-    'PATH_TRANSLATED' : 1, 
-    'SCRIPT_NAME' : 1, 
-    'QUERY_STRING' : 1, 
-    'REMOTE_HOST' : 1, 
-    'REMOTE_ADDR' : 1, 
-    'AUTH_TYPE' : 1, 
-    'REMOTE_USER' : 1, 
-    'REMOTE_IDENT' : 1, 
-    'CONTENT_TYPE' : 1, 
+    'SERVER_SOFTWARE' : 1,
+    'SERVER_NAME' : 1,
+    'GATEWAY_INTERFACE' : 1,
+    'SERVER_PROTOCOL' : 1,
+    'SERVER_PORT' : 1,
+    'REQUEST_METHOD' : 1,
+    'PATH_INFO' : 1,
+    'PATH_TRANSLATED' : 1,
+    'SCRIPT_NAME' : 1,
+    'QUERY_STRING' : 1,
+    'REMOTE_HOST' : 1,
+    'REMOTE_ADDR' : 1,
+    'AUTH_TYPE' : 1,
+    'REMOTE_USER' : 1,
+    'REMOTE_IDENT' : 1,
+    'CONTENT_TYPE' : 1,
     'CONTENT_LENGTH' : 1,
     'SERVER_URL': 1,
     }.has_key
@@ -798,7 +798,7 @@
 
     def setBody(self, body):
         """Sets the body of the response
-        
+
         Sets the return body equal to the (string) argument "body". Also
         updates the "content-length" return header and sets the status to
         200 if it has not already been set.
@@ -873,4 +873,4 @@
 
 
 def is_text_html(content_type):
-    return content_type.startswith('text/html') 
+    return content_type.startswith('text/html')


=== Zope3/src/zope/publisher/http.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/publisher/http.py:1.1.2.3	Tue Dec 24 07:51:28 2002
+++ Zope3/src/zope/publisher/http.py	Tue Dec 24 21:21:14 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
 
@@ -81,7 +81,7 @@
 class HTTPRequest(BaseRequest):
     """
     Model HTTP request data.
-    
+
     This object provides access to request data.  This includes, the
     input headers, form data, server data, and cookies.
 
@@ -130,13 +130,13 @@
                       )
 
     __slots__ = (
-        '_auth',          # The value of the HTTP_AUTHORIZATION header.    
-        '_cookies',       # The request cookies                            
-        '_path_suffix',   # Extra traversal steps after normal traversal   
-        '_retry_count',   # How many times the request has been retried    
-        '_app_url',       # The application URL                            
-        '_app_names',     # The application path as a sequence             
-        '_app_base',      # The application URL without the last name      
+        '_auth',          # The value of the HTTP_AUTHORIZATION header.
+        '_cookies',       # The request cookies
+        '_path_suffix',   # Extra traversal steps after normal traversal
+        '_retry_count',   # How many times the request has been retried
+        '_app_url',       # The application URL
+        '_app_names',     # The application path as a sequence
+        '_app_base',      # The application URL without the last name
         '_app_server',    # The server path of the application url
         '_orig_env',      # The original environment
         '_endswithslash', # Does the given path end with /
@@ -232,7 +232,7 @@
             environ['HTTPS'] == "on" or environ['HTTPS'] == "ON"):
             protocol = 'https'
 
-        elif (have_env('SERVER_PORT_SECURE') and 
+        elif (have_env('SERVER_PORT_SECURE') and
               environ['SERVER_PORT_SECURE'] == "1"):
             protocol = 'https'
         else: protocol = 'http'
@@ -375,10 +375,10 @@
 
 
     def getURL(self, level=0, path_only=0):
-        names = self._app_names + self._traversed_names        
+        names = self._app_names + self._traversed_names
         if level:
             if level > len(names):
-                raise IndexError, level 
+                raise IndexError, level
             names = names[:-level]
         names = [quote(name, safe='/+@') for name in names]
 
@@ -391,13 +391,13 @@
 
     def getApplicationURL(self, depth=0, path_only=0):
         if depth:
-            names = self._traversed_names        
+            names = self._traversed_names
             if depth > len(names):
-                raise IndexError, depth 
+                raise IndexError, depth
             names = self._app_names + names[:depth]
         else:
             names = self._app_names
-            
+
         names =  [quote(name, safe='/+@') for name in names]
 
         if path_only:
@@ -413,7 +413,7 @@
 
         result = self._cookies.get(key, self)
         if result is not self: return result
-        
+
         result = self._environ.get(key, self)
         if result is not self: return result
 
@@ -477,8 +477,8 @@
             name  = unicode(mo_p.group(2), ENCODING)
             value = unicode(mo_p.group(3), ENCODING)
 
-        else: 
-            return result 
+        else:
+            return result
 
     if not already_have(name): result[name]=value
 
@@ -580,7 +580,7 @@
 
     __slots__ = (
         '_header_output',       # Hook object to collaborate with a server
-                                # for header generation. 
+                                # for header generation.
         '_headers',
         '_cookies',
         '_accumulated_headers', # Headers that can have multiples
@@ -597,8 +597,8 @@
         self._header_output = header_output
 
         super(HTTPResponse, self).__init__(outstream)
-        self._headers = {} 
-        self._cookies = {} 
+        self._headers = {}
+        self._cookies = {}
         self._accumulated_headers = []
         self._wrote_headers = 0
         self._streaming = 0
@@ -606,7 +606,7 @@
         self._reason = 'No status set'
         self._status_set = 0
         self._charset = None
-        
+
 
     def setHeaderOutput(self, header_output):
         self._header_output = header_output
@@ -846,7 +846,7 @@
             cookie_list.append(cookie)
 
         # XXX: Should really check size of cookies here!
-        
+
         return cookie_list
 
 
@@ -888,7 +888,7 @@
         cookies on the response object.
 
         Note that published objects must not generate any errors
-        after beginning stream-oriented output. 
+        after beginning stream-oriented output.
 
         """
         self.output(string)
@@ -979,7 +979,7 @@
     if y[1] == 'utf-8':
         return 1
     if x[1] == 'utf-8':
-        return -1    
+        return -1
     return cmp(y, x)
 
 


=== Zope3/src/zope/publisher/maybe_lock.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/publisher/maybe_lock.py:1.1.2.1	Mon Dec 23 14:33:08 2002
+++ Zope3/src/zope/publisher/maybe_lock.py	Tue Dec 24 21:21:14 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 __version__='$Revision$'[11:-2]
 


=== Zope3/src/zope/publisher/publish.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/publisher/publish.py:1.1.2.2	Mon Dec 23 16:04:47 2002
+++ Zope3/src/zope/publisher/publish.py	Tue Dec 24 21:21:14 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """Provide an apply-like facility that works with any mapping object
 """
@@ -55,7 +55,7 @@
         raise TypeError(
             "couldn't find callable metadata, mapply() error on %s"%`object`
         )
-    
+
     return unwrapped, wrapperCount
 
 def mapply(object, positional=(), request={}):
@@ -141,10 +141,10 @@
 
                     except:
                         publication.handleException(object, request, sys.exc_info(), 1)
-                    
+
                         if not handle_errors:
                             raise
-                    
+
                     break # Successful.
 
                 except Retry, retryException:
@@ -161,7 +161,7 @@
                         break
                     else:
                         raise
-                
+
             except:
                 # Bad exception handler or retry method.
                 # Re-raise after outputting the response.
@@ -180,7 +180,3 @@
     finally:
         to_raise = None  # Avoid circ. ref.
         request.close()  # Close database connections, etc.
-
-
-
-


=== Zope3/src/zope/publisher/vfs.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/publisher/vfs.py:1.1.2.2	Tue Dec 24 07:51:28 2002
+++ Zope3/src/zope/publisher/vfs.py	Tue Dec 24 21:21:14 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 """
 
@@ -32,7 +32,7 @@
            It is very important to note that in this case the body may
            not be just a astring, but any Python object.
         """
-        
+
         self._body = body
 
 
@@ -66,8 +66,8 @@
     __implements__ = IVFSView
 
     def __init__(self, context, request):
-       self.context = context
-       self.request = request
+        self.context = context
+        self.request = request
 
 
 """
@@ -85,7 +85,7 @@
 
     __implements__ = BaseRequest.__implements__, IVFSCredentials
 
-    # _presentation_type is overridden from the BaseRequest 
+    # _presentation_type is overridden from the BaseRequest
     # to implement IVFSView
     _presentation_type = IVFSView
 
@@ -133,7 +133,7 @@
 
 """VFS-View for IFile
 
-VFS-view implementation for a generic file. 
+VFS-view implementation for a generic file.
 
 $Id$
 """
@@ -168,7 +168,7 @@
 
     def read(self, mode, outstream, start = 0, end = -1):
         """See IVFSFilePublisher"""
-        
+
         data = self._getData()
         try:
             if end != -1: data = data[:end]


=== Zope3/src/zope/publisher/xmlrpc.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/publisher/xmlrpc.py:1.1.2.2	Tue Dec 24 07:51:28 2002
+++ Zope3/src/zope/publisher/xmlrpc.py	Tue Dec 24 21:21:14 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
 
@@ -20,7 +20,7 @@
 
 class MethodPublisher(DefaultPublisher):
     """Simple XML-RPC publisher that is identical to the HTTP Default Publisher
-       except that it implements the IXMLRPCPublisher interface. 
+       except that it implements the IXMLRPCPublisher interface.
     """
 
     __implements__ = IXMLRPCPublisher
@@ -44,7 +44,7 @@
 
     __implements__ = HTTPRequest.__implements__, IXMLRPCPublication
 
-    # _presentation_type is overridden from the BaseRequest 
+    # _presentation_type is overridden from the BaseRequest
     # to implement IXMLRPCPublisher
     _presentation_type = IXMLRPCPresentation
 
@@ -112,17 +112,17 @@
     """
 
     __implements__ = HTTPResponse.__implements__
-    
+
 
     def setBody(self, body):
         """Sets the body of the response
-        
+
         Sets the return body equal to the (string) argument "body". Also
         updates the "content-length" return header.
 
         If the body is a 2-element tuple, then it will be treated
         as (title,body)
-        
+
         If is_error is true then the HTML will be formatted as a Zope error
         message instead of a generic HTML page.
         """
@@ -195,6 +195,5 @@
     __implements__ = IXMLRPCView
 
     def __init__(self, context, request):
-       self.context = context
-       self.request = request
-
+        self.context = context
+        self.request = request