[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - Converters.py:1.18.4.7 HTTPRequest.py:1.80.2.8 HTTPResponse.py:1.69.2.6
Chris McDonough
chrism@zope.com
Fri, 3 Jan 2003 01:42:12 -0500
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv29376
Modified Files:
Tag: chrism-install-branch
Converters.py HTTPRequest.py HTTPResponse.py
Log Message:
Merging chrism-install-branch with HEAD (hopefully for one of the last
times).
=== Zope/lib/python/ZPublisher/Converters.py 1.18.4.6 => 1.18.4.7 ===
--- Zope/lib/python/ZPublisher/Converters.py:1.18.4.6 Sun Nov 24 18:57:27 2002
+++ Zope/lib/python/ZPublisher/Converters.py Fri Jan 3 01:42:09 2003
@@ -14,6 +14,7 @@
import re
from types import ListType, TupleType, UnicodeType
+from DateTime import DateTime
from cgi import escape
def field2string(v):
@@ -47,7 +48,7 @@
raise ValueError, 'No input for required field<p>'
def field2int(v):
- if type(v) in (ListType, TupleType):
+ if isinstance(v, (ListType, TupleType)):
return map(field2int, v)
v = field2string(v)
if v:
@@ -59,7 +60,7 @@
raise ValueError, 'Empty entry when <strong>integer</strong> expected'
def field2float(v):
- if type(v) in (ListType, TupleType):
+ if isinstance(v, (ListType, TupleType)):
return map(field2float, v)
v = field2string(v)
if v:
@@ -73,7 +74,7 @@
'Empty entry when <strong>floating-point number</strong> expected')
def field2long(v):
- if type(v) in (ListType, TupleType):
+ if isinstance(v, (ListType, TupleType)):
return map(field2long, v)
v = field2string(v)
# handle trailing 'L' if present.
@@ -92,7 +93,7 @@
return v.split()
def field2lines(v):
- if type(v) in (ListType, TupleType):
+ if isinstance(v, (ListType, TupleType)):
result=[]
for item in v:
result.append(str(item))
@@ -100,7 +101,7 @@
return field2text(v).split('\n')
def field2date(v):
- from DateTime import DateTime
+
v = field2string(v)
try:
v = DateTime(v)
@@ -108,6 +109,14 @@
raise DateTime.SyntaxError, escape(e)
return v
+def field2date_international(v):
+ v = field2string(v)
+ try:
+ v = DateTime(v, datefmt="international")
+ except DateTime.SyntaxError, e:
+ raise DateTime.SyntaxError, escape(e)
+ return v
+
def field2boolean(v):
return not not v
@@ -152,6 +161,7 @@
'long': field2long,
'string': field2string,
'date': field2date,
+ 'date_international': field2date_international,
'required': field2required,
'tokens': field2tokens,
'lines': field2lines,
=== Zope/lib/python/ZPublisher/HTTPRequest.py 1.80.2.7 => 1.80.2.8 ===
--- Zope/lib/python/ZPublisher/HTTPRequest.py:1.80.2.7 Sun Nov 24 18:57:27 2002
+++ Zope/lib/python/ZPublisher/HTTPRequest.py Fri Jan 3 01:42:09 2003
@@ -25,10 +25,6 @@
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,
'SERVER_NAME' : 1,
@@ -343,7 +339,7 @@
hasattr=hasattr,
getattr=getattr,
setattr=setattr,
- search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search,
+ search_type=re.compile('(:[a-zA-Z][-a-zA-Z0-9_]+|\\.[xy])$').search,
):
"""Process request inputs
=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.69.2.5 => 1.69.2.6 ===
--- Zope/lib/python/ZPublisher/HTTPResponse.py:1.69.2.5 Sun Nov 24 18:57:27 2002
+++ Zope/lib/python/ZPublisher/HTTPResponse.py Fri Jan 3 01:42:09 2003
@@ -233,6 +233,8 @@
literal flag is true, the case of the header name is preserved,
otherwise word-capitalization will be performed on the header
name on output.'''
+ name = str(name)
+ value = str(value)
key = name.lower()
if accumulate_header(key):
self.accumulated_headers = (
@@ -245,6 +247,8 @@
'''\
Set a new HTTP return header with the given value, while retaining
any previously set headers with the same name.'''
+ name = str(name)
+ value = str(value)
self.accumulated_headers = (
"%s%s: %s\n" % (self.accumulated_headers, name, value))
@@ -423,10 +427,13 @@
return body.encode('latin1','replace')
def setBase(self,base):
- 'Set the base URL for the returned document.'
- if not base.endswith('/'):
+ """Set the base URL for the returned document.
+ If base is None, or the document already has a base, do nothing."""
+ if base is None:
+ base = ''
+ elif not base.endswith('/'):
base = base+'/'
- self.base = base
+ self.base = str(base)
def insertBase(self,
base_re_search=re.compile('(<base.*?>)',re.I).search
@@ -456,6 +463,9 @@
cookie has previously been set in the response object, the new
value is appended to the old one separated by a colon. '''
+ name = str(name)
+ value = str(value)
+
cookies = self.cookies
if cookies.has_key(name):
cookie = cookies[name]
@@ -478,6 +488,8 @@
when creating the cookie. The path can be specified as a keyword
argument.
'''
+ name = str(name)
+
dict = {'max_age':0, 'expires':'Wed, 31-Dec-97 23:59:59 GMT'}
for k, v in kw.items():
dict[k] = v
@@ -492,6 +504,9 @@
"value". This overwrites any previously set value for the
cookie in the Response object.
'''
+ name = str(name)
+ value = str(value)
+
cookies = self.cookies
if cookies.has_key(name):
cookie = cookies[name]
@@ -508,6 +523,9 @@
Sets an HTTP return header "name" with value "value",
appending it following a comma if there was a previous value
set for the header. '''
+ name = str(name)
+ value = str(value)
+
headers = self.headers
if headers.has_key(name):
h = headers[name]
@@ -544,6 +562,8 @@
"""Cause a redirection without raising an error"""
self.setStatus(status)
self.setHeader('Location', location)
+
+ location = str(location)
if lock:
# Don't let anything change the status code.