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