[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - cgi_hotfix.py:1.2.2.1 Converters.py:1.11.24.1 HTTPRequest.py:1.54.8.1 HTTPResponse.py:1.46.24.1

Shane Hathaway shane@digicool.com
Thu, 9 Aug 2001 13:34:15 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv29115/lib/python/ZPublisher

Modified Files:
      Tag: NR-branch
	Converters.py HTTPRequest.py HTTPResponse.py 
Added Files:
      Tag: NR-branch
	cgi_hotfix.py 
Log Message:
Sync NR-branch with trunk.  Sorry about so many checkin messages...


=== Added File Zope/lib/python/ZPublisher/cgi_hotfix.py ===
def set_read_multi():
    import re
    global valid_boundary
    valid_boundary = re.compile("^[ -~]{0,200}[!-~]$").match

    def read_multi(self, environ, keep_blank_values, strict_parsing):
        """Internal: read a part that is itself multipart."""
        ib = self.innerboundary
        if not valid_boundary(ib):
            raise ValueError, ('Invalid boundary in multipart form: %s' 
                               % `ib`)
        self.list = []
        klass = self.FieldStorageClass or self.__class__
        part = klass(self.fp, {}, ib,
                     environ, keep_blank_values, strict_parsing)
        # Throw first part away
        while not part.done:
            headers = rfc822.Message(self.fp)
            part = klass(self.fp, headers, ib,
                         environ, keep_blank_values, strict_parsing)
            self.list.append(part)
        self.skip_lines()
    FieldStorage.read_multi = read_multi

import cgi
exec set_read_multi.func_code in cgi.__dict__


=== Zope/lib/python/ZPublisher/Converters.py 1.11 => 1.11.24.1 ===
     return v
 
-def field2text(v, nl=re.compile('\r\n\|\n\r').search):
+def field2text(v, nl=re.compile('\r\n|\n\r').search):
     if hasattr(v,'read'): v=v.read()
     else: v=str(v)
     mo = nl(v)


=== Zope/lib/python/ZPublisher/HTTPRequest.py 1.54 => 1.54.8.1 ===
 __version__='$Revision$'[11:-2]
 
-import  re, sys, os, string, urllib, time, whrandom
+import re, sys, os, string, urllib, time, whrandom, cgi
 from string import lower, atoi, rfind, split, strip, join, upper, find
 from BaseRequest import BaseRequest
 from HTTPResponse import HTTPResponse
@@ -94,6 +94,10 @@
 from Converters import get_converter
 from maybe_lock import allocate_lock
 xmlrpc=None # Placeholder for module that we'll import if we have to.
+
+#cgi hotfix:
+if not hasattr(cgi, 'valid_boundary'):
+    import cgi_hotfix
 
 isCGI_NAME = {
         'SERVER_SOFTWARE' : 1, 


=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.46 => 1.46.24.1 ===
         # XXX could this try to use standard_error_message somehow?
         return ("""\
-<HTML>
-<HEAD><TITLE>Site Error</TITLE></HEAD>
-<BODY>
-
 <TABLE BORDER="0" WIDTH="100%">
 <TR VALIGN="TOP">
 
@@ -535,18 +531,15 @@
   Thank you for your patience.
   </P>
 </TD></TR>
-</TABLE>
-
-</BODY>
-</HTML>""")
+</TABLE>""")
 
-    def notFoundError(self,entry='who knows!'):
+    def notFoundError(self,entry='Unknown'):
         self.setStatus(404)
         raise 'NotFound',self._error_html(
             "Resource not found",
-            "Sorry, the requested resource does not exist.<p>" +
-            "Check the URL and try again.<p>" +
-            "\n<!--\n%s\n-->" % entry)
+            "Sorry, the requested resource does not exist." +
+            "<p>Check the URL and try again.</p>" +
+            "<p><b>Resource:</b> %s</p>" % self.quoteHTML(entry))
 
     forbiddenError=notFoundError  # If a resource is forbidden,
                                   # why reveal that it exists?