[Zope-Checkins] SVN: Zope/branches/2.13/ Added forward compatibility with DateTime 3 by backporting c121602 and c121606 from trunk
Hanno Schlichting
hannosch at hannosch.eu
Sun May 8 13:10:23 EDT 2011
Log message for revision 121617:
Added forward compatibility with DateTime 3 by backporting c121602 and c121606 from trunk
Changed:
U Zope/branches/2.13/doc/CHANGES.rst
U Zope/branches/2.13/src/App/PersistentExtra.py
U Zope/branches/2.13/src/ZPublisher/Converters.py
U Zope/branches/2.13/src/ZPublisher/tests/testHTTPRequest.py
U Zope/branches/2.13/src/ZPublisher/xmlrpc.py
-=-
Modified: Zope/branches/2.13/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.13/doc/CHANGES.rst 2011-05-08 17:07:50 UTC (rev 121616)
+++ Zope/branches/2.13/doc/CHANGES.rst 2011-05-08 17:10:23 UTC (rev 121617)
@@ -15,6 +15,8 @@
Features Added
++++++++++++++
+- Added forward compatibility with DateTime 3.
+
- ZPublisher: HTTPResponse.appendHeader now keeps header values to a single
line by default to avoid causing problems for proxy servers which do not
correctly handle multi-line headers.
Modified: Zope/branches/2.13/src/App/PersistentExtra.py
===================================================================
--- Zope/branches/2.13/src/App/PersistentExtra.py 2011-05-08 17:07:50 UTC (rev 121616)
+++ Zope/branches/2.13/src/App/PersistentExtra.py 2011-05-08 17:10:23 UTC (rev 121617)
@@ -18,14 +18,14 @@
class PersistentUtil:
def bobobase_modification_time(self):
- jar=self._p_jar
- oid=self._p_oid
+ jar = self._p_jar
+ oid = self._p_oid
if jar is None or oid is None:
return DateTime()
try:
t = self._p_mtime
- except:
+ except AttributeError:
t = 0
return DateTime(t)
Modified: Zope/branches/2.13/src/ZPublisher/Converters.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/Converters.py 2011-05-08 17:07:50 UTC (rev 121616)
+++ Zope/branches/2.13/src/ZPublisher/Converters.py 2011-05-08 17:10:23 UTC (rev 121617)
@@ -14,6 +14,7 @@
import re
from types import ListType, TupleType, UnicodeType
from DateTime import DateTime
+from DateTime.interfaces import SyntaxError
from cgi import escape
# This may get overwritten during configuration
@@ -106,16 +107,16 @@
v = field2string(v)
try:
v = DateTime(v)
- except DateTime.SyntaxError, e:
- raise DateTime.SyntaxError, "Invalid DateTime "+escape(`v`)
+ except SyntaxError:
+ raise SyntaxError("Invalid DateTime " + escape(repr(v)))
return v
def field2date_international(v):
v = field2string(v)
try:
v = DateTime(v, datefmt="international")
- except DateTime.SyntaxError, e:
- raise DateTime.SyntaxError, "Invalid DateTime "+escape(`v`)
+ except SyntaxError:
+ raise SyntaxError("Invalid DateTime " + escape(repr(v)))
return v
def field2boolean(v):
Modified: Zope/branches/2.13/src/ZPublisher/tests/testHTTPRequest.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/tests/testHTTPRequest.py 2011-05-08 17:07:50 UTC (rev 121616)
+++ Zope/branches/2.13/src/ZPublisher/tests/testHTTPRequest.py 2011-05-08 17:10:23 UTC (rev 121617)
@@ -573,15 +573,15 @@
def test_processInputs_w_tainted_values_cleans_exceptions(self):
# Feed tainted garbage to the conversion methods, and any exception
# returned should be HTML safe
- from DateTime.DateTime import DateTime
+ from DateTime.interfaces import SyntaxError
from ZPublisher.Converters import type_converters
for type, convert in type_converters.items():
try:
convert('<html garbage>')
- except Exception, e:
+ except Exception as e:
self.assertFalse('<' in e.args,
'%s converter does not quote unsafe value!' % type)
- except DateTime.SyntaxError, e:
+ except SyntaxError as e:
self.assertFalse('<' in e,
'%s converter does not quote unsafe value!' % type)
Modified: Zope/branches/2.13/src/ZPublisher/xmlrpc.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/xmlrpc.py 2011-05-08 17:07:50 UTC (rev 121616)
+++ Zope/branches/2.13/src/ZPublisher/xmlrpc.py 2011-05-08 17:10:23 UTC (rev 121617)
@@ -32,7 +32,7 @@
# Make DateTime.DateTime marshallable via XML-RPC
# http://www.zope.org/Collectors/Zope/2109
from DateTime.DateTime import DateTime
-WRAPPERS = xmlrpclib.WRAPPERS + (DateTime,)
+WRAPPERS = xmlrpclib.WRAPPERS + (DateTime, )
def dump_instance(self, value, write):
# Check for special wrappers
@@ -50,7 +50,9 @@
self.dump_struct(value, write)
xmlrpclib.Marshaller.dispatch[types.InstanceType] = dump_instance
+xmlrpclib.Marshaller.dispatch[DateTime] = dump_instance
+
def parse_input(data):
"""Parse input data and return a method path and argument tuple
More information about the Zope-Checkins
mailing list