[Zope-Coders] Re: [Zope-Checkins] CVS:
Zope/lib/python/Products/PluginIndexes/DateRangeIndex -
DateRangeIndex.py:1.6.2.2
Tres Seaver
tseaver at zope.com
Mon Nov 3 20:03:52 EST 2003
On Sun, 2003-11-02 at 06:59, Chris McDonough wrote:
> Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/DateRangeIndex
> In directory cvs.zope.org:/tmp/cvs-serv30007
>
> Modified Files:
> Tag: Zope-2_7-branch
> DateRangeIndex.py
> Log Message:
> DateRangeIndexes blew up when attempting to store a date far in the future ( > Y2038 ). This is a workaround. The real fix would be to come up with a different conversion algorithm or to use OOBTrees to store datum.
I think a better fix here would be to raise ValueError if the Date is
outside the "int-able" range; otherwise, we end up moving the
"surprise" point for the one where we have information (indexing) to the
one where we don't (querying).
>
>
> === Zope/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py 1.6.2.1 => 1.6.2.2 ===
> --- Zope/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py:1.6.2.1 Thu Sep 18 10:16:14 2003
> +++ Zope/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py Sun Nov 2 06:59:12 2003
> @@ -15,6 +15,7 @@
> """
>
> import os
> +import sys
>
> from Products.PluginIndexes import PluggableIndex
> from Products.PluginIndexes.common.UnIndex import UnIndex
> @@ -404,6 +405,15 @@
> 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 )
>
> InitializeClass( DateRangeIndex )
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the Zope-Coders
mailing list