Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
a4e1e8a3
Commit
a4e1e8a3
authored
Nov 04, 2003
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove magical cast to int. Raise a ValueError explicitly when we
notice that the date is a long.
parent
60d04a03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
...n/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
+6
-11
lib/python/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
...PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
+8
-0
No files found.
lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
View file @
a4e1e8a3
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
##############################################################################
##############################################################################
"""$Id: DateRangeIndex.py,v 1.
8 2003/11/02 11:57:5
8 chrism Exp $
"""$Id: DateRangeIndex.py,v 1.
9 2003/11/04 14:53:2
8 chrism Exp $
"""
"""
import
os
import
os
...
@@ -405,16 +405,11 @@ class DateRangeIndex(UnIndex):
...
@@ -405,16 +405,11 @@ class DateRangeIndex(UnIndex):
value
=
dt_obj
.
millis
()
/
1000
/
60
# flatten to minutes
value
=
dt_obj
.
millis
()
/
1000
/
60
# flatten to minutes
if
isinstance
(
value
,
DateTime
):
if
isinstance
(
value
,
DateTime
):
value
=
value
.
millis
()
/
1000
/
60
# flatten to minutes
value
=
value
.
millis
()
/
1000
/
60
# flatten to minutes
# XXX 2038K bug:
result
=
int
(
value
)
# we might still be dealing with a long.
if
isinstance
(
result
,
long
):
# this won't work
# we're using IOBTrees with dates as keys and we
raise
ValueError
(
'%s is not within the range of dates allowed'
# cant convert long to int if its > sys.maxint.
'by a DateRangeIndex'
%
value
)
# BTrees code blows up if we try to ask it for a long key,
return
result
# 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
)
InitializeClass
(
DateRangeIndex
)
...
...
lib/python/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
View file @
a4e1e8a3
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
import
Zope
import
Zope
import
unittest
import
unittest
import
sys
from
Products.PluginIndexes.DateRangeIndex.DateRangeIndex
import
DateRangeIndex
from
Products.PluginIndexes.DateRangeIndex.DateRangeIndex
import
DateRangeIndex
...
@@ -111,6 +112,13 @@ class DRI_Tests( unittest.TestCase ):
...
@@ -111,6 +112,13 @@ class DRI_Tests( unittest.TestCase ):
for
result
,
match
in
map
(
None
,
results
,
matches
):
for
result
,
match
in
map
(
None
,
results
,
matches
):
assert
work
.
getEntryForObject
(
result
)
==
match
.
datum
()
assert
work
.
getEntryForObject
(
result
)
==
match
.
datum
()
def
test_longdates
(
self
):
self
.
assertRaises
(
ValueError
,
self
.
_badlong
)
def
_badlong
(
self
):
work
=
DateRangeIndex
(
'work'
,
'start'
,
'stop'
)
bad
=
Dummy
(
'bad'
,
sys
.
maxint
+
1
,
sys
.
maxint
+
1
)
work
.
index_object
(
0
,
bad
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment