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

Stephan Richter srichter@cbu.edu
Thu, 13 Jun 2002 20:57:49 -0400


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

Modified Files:
	BrowserRequest.py 
Log Message:
Wrote some code that will convert form and cookie keys and values to
unicode, assuming an UTF-8 encoding. At some point we should probably find
a way to set the encoding based on a place. But this requires some more
serious infrastructure changes and should be discussed first. For now I am
happy that all the input is unicodefied.


=== Zope3/lib/python/Zope/Publisher/Browser/BrowserRequest.py 1.4 => 1.5 ===
 from cgi import FieldStorage
 from cgi_names import isCGI_NAME, hide_key
+from types import StringType
 from Zope.Publisher.Converters import get_converter
 from Zope.Publisher.HTTP.HTTPRequest import HTTPRequest
 from IBrowserPresentation import IBrowserPresentation
@@ -29,6 +30,9 @@
 from IBrowserApplicationRequest import IBrowserApplicationRequest
 from BrowserResponse import BrowserResponse
 
+# Default Encoding
+ENCODING = 'UTF-8'
+
 # Flas Constants
 SEQUENCE = 1
 DEFAULT = 2
@@ -119,7 +123,7 @@
                         item = item.value
 
                 flags = 0
-
+                
                 # Loop through the different types and set
                 # the appropriate flags
                 # Syntax: var_name:type_name
@@ -182,6 +186,11 @@
                 # Filter out special names from form:
                 if CGI_name(key) or key.startswith('HTTP_'):
                     continue
+                
+                # Make it unicode
+                key = unicode(key, ENCODING)
+                if type(item) == StringType:
+                    item = unicode(item, ENCODING)
 
                 if flags:
 
@@ -411,6 +420,8 @@
         if meth:
             self.setPathSuffix((meth,))
 
+        #print self.form
+
     ######################################
     # from: Zope.Publisher.IPublisherRequest.IPublisherRequest
     def traverse(self, object):
@@ -487,7 +498,7 @@
     #
     ############################################################
 
-class FileUpload:
+class FileUpload(object):
     '''\
     File upload objects