Commit 236f4d0a authored by Hanno Schlichting's avatar Hanno Schlichting

Backported c115442, 115445 and 115501 from trunk to deal with changes in ZODB 3.9.6

parent 1e7fb77a
......@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- Adjusted overflow logic in DateIndex and DateRangeIndex to work with latest
ZODB 3.9.7.
- Fixed ``testZODBCompat`` tests in ZopeTestCase to match modern ZODB
semantics.
......
......@@ -53,6 +53,8 @@ else:
DSTOFFSET = STDOFFSET
DSTDIFF = DSTOFFSET - STDOFFSET
MAX32 = int(2**31 - 1)
class LocalTimezone(tzinfo):
......@@ -262,9 +264,9 @@ class DateIndex(UnIndex, PropertyManager):
t_val = ( ( ( ( yr * 12 + mo ) * 31 + dy ) * 24 + hr ) * 60 + mn )
if isinstance(t_val, long):
# t_val must be IntType, not LongType
raise OverflowError, (
if t_val > MAX32:
# t_val must be integer fitting in the 32bit range
raise OverflowError(
"%s is not within the range of indexable dates (index: %s)"
% (value, self.id))
......
......@@ -40,6 +40,7 @@ from Products.PluginIndexes.common.util import parseIndexRequest
from Products.PluginIndexes.interfaces import IDateRangeIndex
_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
MAX32 = int(2**31 - 1)
class DateRangeIndex(UnIndex):
......@@ -421,7 +422,8 @@ class DateRangeIndex(UnIndex):
elif isinstance(value, DateTime):
value = value.millis() / 1000 / 60 # flatten to minutes
result = int( value )
if isinstance(result, long): # this won't work (Python 2.3)
if result > MAX32:
# t_val must be integer fitting in the 32bit range
raise OverflowError( '%s is not within the range of dates allowed'
'by a DateRangeIndex' % value)
return result
......
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