Skip to content

Commit

Permalink
modified time can be a long.
Browse files Browse the repository at this point in the history
Fixes plone.namedfile and plone.app.imaging tests.
  • Loading branch information
mauritsvanrees committed Oct 23, 2016
1 parent 329796c commit 1c3ce6e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions plone/scale/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
# This is one day:
KEEP_SCALE_MILLIS = 24 * 60 * 60 * 1000

try:
long
except NameError:
# Python 3 has no long, only int.
number_types = (float, int)
else:
# Python 2
number_types = (float, int, long)


class IImageScaleStorage(Interface):
""" This is an adapter for image content which can store, retrieve and
Expand Down Expand Up @@ -118,12 +127,12 @@ def _modified_since(self, since, offset=0):
modified_time = self.modified_time
if modified_time is None:
return False
# We expect either a float or an int, but in corner cases it can be
# We expect a number, but in corner cases it can be
# something else entirely.
# https://github.com/plone/plone.scale/issues/12
if not isinstance(modified_time, (float, int)):
if not isinstance(modified_time, number_types):
return False
if not isinstance(since, (float, int)):
if not isinstance(since, number_types):
return False
since = since - offset
return modified_time > since
Expand Down Expand Up @@ -234,7 +243,7 @@ def _cleanup(self):
modified_time = self.modified_time
if modified_time is None:
return
if not isinstance(modified_time, (float, int)):
if not isinstance(modified_time, number_types):
# https://github.com/plone/plone.scale/issues/12
return
for key, value in storage.items():
Expand Down

0 comments on commit 1c3ce6e

Please sign in to comment.