[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/DateRangeIndex - DateRangeIndex.py:1.9

Chris McDonough cvs-admin at zope.org
Tue Nov 4 09:53:59 EST 2003


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/DateRangeIndex
In directory cvs.zope.org:/tmp/cvs-serv27866

Modified Files:
	DateRangeIndex.py 
Log Message:
Remove magical cast to int.  Raise a ValueError explicitly when we
notice that the date is a long.


=== Zope/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py 1.8 => 1.9 ===
--- Zope/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py:1.8	Sun Nov  2 06:57:58 2003
+++ Zope/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py	Tue Nov  4 09:53:28 2003
@@ -405,16 +405,11 @@
             value = dt_obj.millis() / 1000 / 60 # flatten to minutes
         if isinstance( value, DateTime ):
             value = value.millis() / 1000 / 60 # flatten to minutes
-        # XXX 2038K bug:
-        # we might still be dealing with a long.
-        # we're using IOBTrees with dates as keys and we
-        # cant convert long to int if its > sys.maxint.
-        # BTrees code blows up if we try to ask it for a long key,
-        # so we punt here.  In a future version, we should either
-        # come up with a LOBTree or use OOBTrees to store datum.
-        if value > sys.maxint: 
-            value = sys.maxint
-        return int( value )
+        result = int( value )
+        if isinstance(result, long): # this won't work
+            raise ValueError( '%s is not within the range of dates allowed'
+                              'by a DateRangeIndex' % value)
+        return result
 
 InitializeClass( DateRangeIndex )
 




More information about the Zope-Checkins mailing list