Commit d8d50950 authored by Hanno Schlichting's avatar Hanno Schlichting

Some cleanup and fixes for changed DateTime.SyntaxError import location

parent 69a1fb1f
...@@ -18,14 +18,14 @@ from DateTime.DateTime import DateTime ...@@ -18,14 +18,14 @@ from DateTime.DateTime import DateTime
class PersistentUtil: class PersistentUtil:
def bobobase_modification_time(self): def bobobase_modification_time(self):
jar=self._p_jar jar = self._p_jar
oid=self._p_oid oid = self._p_oid
if jar is None or oid is None: if jar is None or oid is None:
return DateTime() return DateTime()
try: try:
t = self._p_mtime t = self._p_mtime
except: except AttributeError:
t = 0 t = 0
return DateTime(t) return DateTime(t)
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
import re import re
from types import ListType, TupleType, UnicodeType from types import ListType, TupleType, UnicodeType
from DateTime import DateTime from DateTime import DateTime
from DateTime.interfaces import SyntaxError
from cgi import escape from cgi import escape
# This may get overwritten during configuration # This may get overwritten during configuration
...@@ -106,16 +107,16 @@ def field2date(v): ...@@ -106,16 +107,16 @@ def field2date(v):
v = field2string(v) v = field2string(v)
try: try:
v = DateTime(v) v = DateTime(v)
except DateTime.SyntaxError, e: except SyntaxError:
raise DateTime.SyntaxError, "Invalid DateTime "+escape(`v`) raise SyntaxError("Invalid DateTime " + escape(repr(v)))
return v return v
def field2date_international(v): def field2date_international(v):
v = field2string(v) v = field2string(v)
try: try:
v = DateTime(v, datefmt="international") v = DateTime(v, datefmt="international")
except DateTime.SyntaxError, e: except SyntaxError:
raise DateTime.SyntaxError, "Invalid DateTime "+escape(`v`) raise SyntaxError("Invalid DateTime " + escape(repr(v)))
return v return v
def field2boolean(v): def field2boolean(v):
......
...@@ -580,15 +580,15 @@ class HTTPRequestTests(unittest.TestCase): ...@@ -580,15 +580,15 @@ class HTTPRequestTests(unittest.TestCase):
def test_processInputs_w_tainted_values_cleans_exceptions(self): def test_processInputs_w_tainted_values_cleans_exceptions(self):
# Feed tainted garbage to the conversion methods, and any exception # Feed tainted garbage to the conversion methods, and any exception
# returned should be HTML safe # returned should be HTML safe
from DateTime.DateTime import DateTime from DateTime.interfaces import SyntaxError
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
for type, convert in type_converters.items(): for type, convert in type_converters.items():
try: try:
convert('<html garbage>') convert('<html garbage>')
except Exception, e: except Exception as e:
self.assertFalse('<' in e.args, self.assertFalse('<' in e.args,
'%s converter does not quote unsafe value!' % type) '%s converter does not quote unsafe value!' % type)
except DateTime.SyntaxError, e: except SyntaxError as e:
self.assertFalse('<' in e, self.assertFalse('<' in e,
'%s converter does not quote unsafe value!' % type) '%s converter does not quote unsafe value!' % type)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment