Commit b40c209a authored by Łukasz Nowak's avatar Łukasz Nowak

Support optional parameter.

Also use bobobase_modification_time as fallback.
parent 51cbf893
...@@ -70,7 +70,7 @@ def requireHeader(header_dict): ...@@ -70,7 +70,7 @@ def requireHeader(header_dict):
return wrapperRequireHeader return wrapperRequireHeader
return outer return outer
def supportModifiedSince(document_url_id): def supportModifiedSince(document_url_id=None):
def outer(fn): def outer(fn):
def wrapperSupportModifiedSince(self, *args, **kwargs): def wrapperSupportModifiedSince(self, *args, **kwargs):
modified_since = self.REQUEST.getHeader('If-Modified-Since') modified_since = self.REQUEST.getHeader('If-Modified-Since')
...@@ -86,9 +86,13 @@ def supportModifiedSince(document_url_id): ...@@ -86,9 +86,13 @@ def supportModifiedSince(document_url_id):
# client send date before current time, shall continue and # client send date before current time, shall continue and
# compare with second precision, as client by default shall set # compare with second precision, as client by default shall set
# If-Modified-Since to last known Last-Modified value # If-Modified-Since to last known Last-Modified value
if int(self.restrictedTraverse(getattr(self, document_url_id) if document_url_id is None:
).getModificationDate().timeTime()) <= int( document = self
modified_since.timeTime()): else:
document = self.restrictedTraverse(getattr(self, document_url_id))
document_date = document.getModificationDate() or \
self.bobobase_modification_time()
if int(document_date.timeTime()) <= int(modified_since.timeTime()):
# document was not modified since # document was not modified since
self.REQUEST.response.setStatus(304) self.REQUEST.response.setStatus(304)
return self.REQUEST.response return self.REQUEST.response
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment