Commit a5a09083 authored by Hanno Schlichting's avatar Hanno Schlichting

Adjusted overflow logic in DateIndex and DateRangeIndex to work with latest...

Adjusted overflow logic in DateIndex and DateRangeIndex to work with latest ZODB 3.10.0b4. Instead of an OverflowError a TypeError is raised now.
parent ccc997e7
...@@ -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.10.0b4.
- Made sure to exclude a number of meta ZCML handlers from ``zope.*`` packages - Made sure to exclude a number of meta ZCML handlers from ``zope.*`` packages
where Zope2 provides its own implementations. where Zope2 provides its own implementations.
......
...@@ -51,6 +51,7 @@ else: ...@@ -51,6 +51,7 @@ else:
DSTOFFSET = STDOFFSET DSTOFFSET = STDOFFSET
DSTDIFF = DSTOFFSET - STDOFFSET DSTDIFF = DSTOFFSET - STDOFFSET
MAX32 = 2**31
class LocalTimezone(tzinfo): class LocalTimezone(tzinfo):
...@@ -263,9 +264,11 @@ class DateIndex(UnIndex, PropertyManager): ...@@ -263,9 +264,11 @@ 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):
# 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)" "%s is not within the range of indexable dates (index: %s)"
% (value, self.id)) % (value, self.id))
......
...@@ -37,6 +37,7 @@ from Products.PluginIndexes.common.util import parseIndexRequest ...@@ -37,6 +37,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 = 2**31
class DateRangeIndex(UnIndex): class DateRangeIndex(UnIndex):
...@@ -397,7 +398,8 @@ class DateRangeIndex(UnIndex): ...@@ -397,7 +398,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