[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ Changes related to file mtime handling
Patrick Gerken
do3ccqrv at gmail.com
Wed Nov 23 16:50:07 UTC 2011
Log message for revision 123475:
Changes related to file mtime handling
- unify access to mtime information
- Handle case where if-modified-since caching fails
because depending on platform, mtime can be stored
with subsecond precision, and then the second precision
if-modified-since time will always be older
Changed:
U Products.CMFCore/trunk/Products/CMFCore/tests/test_FSFile.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_FSImage.py
U Products.CMFCore/trunk/Products/CMFCore/utils.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_FSFile.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_FSFile.py 2011-11-23 15:56:12 UTC (rev 123474)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_FSFile.py 2011-11-23 16:50:04 UTC (rev 123475)
@@ -134,10 +134,11 @@
file = self._makeOne('test_file', 'test_file.swf')
file = file.__of__(self.app)
- mod_time = os.stat(path)[8]
+ mod_time = os.stat(path).st_mtime
self.REQUEST.environ['IF_MODIFIED_SINCE'
] = '%s;' % rfc1123_date(mod_time)
+
self.REQUEST.environ['IF_NONE_MATCH'
] = '%s;' % FAKE_ETAG
@@ -153,7 +154,7 @@
file = self._makeOne('test_file', 'test_file.swf')
file = file.__of__(self.app)
- mod_time = os.stat(path)[8]
+ mod_time = os.stat(path).st_mtime
data = file.index_html(self.REQUEST, self.RESPONSE)
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_FSImage.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_FSImage.py 2011-11-23 15:56:12 UTC (rev 123474)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_FSImage.py 2011-11-23 16:50:04 UTC (rev 123475)
@@ -125,7 +125,7 @@
file = self._makeOne('test_file', 'test_image.gif')
file = file.__of__(self.app)
- mod_time = os.stat(path)[8]
+ mod_time = os.stat(path).st_mtime
self.REQUEST.environ['IF_MODIFIED_SINCE'
] = '%s;' % rfc1123_date(mod_time)
@@ -144,7 +144,7 @@
file = self._makeOne('test_file', 'test_image.gif')
file = file.__of__(self.app)
- mod_time = os.stat(path)[8]
+ mod_time = os.stat(path).st_mtime
data = file.index_html(self.REQUEST, self.RESPONSE)
Modified: Products.CMFCore/trunk/Products/CMFCore/utils.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/utils.py 2011-11-23 15:56:12 UTC (rev 123474)
+++ Products.CMFCore/trunk/Products/CMFCore/utils.py 2011-11-23 16:50:04 UTC (rev 123475)
@@ -838,7 +838,9 @@
RESPONSE = REQUEST.RESPONSE
header = REQUEST.getHeader('If-Modified-Since', None)
- last_mod = obj._file_mod_time
+ # Reduce resolution to one second, else if-modified-since would
+ # always be older if system resolution is higher
+ last_mod = int(obj._file_mod_time)
if header is not None:
header = header.split(';')[0]
More information about the checkins
mailing list