#NEWLINE# def modified( date = None , etag = None ) : #NEWLINE# #INDENT# "\n    Checks to see if the page has been modified since the version in the\n    requester's cache.\n    \n    When you publish pages, you can include `Last-Modified` and `ETag`\n    with the date the page was last modified and an opaque token for\n    the particular version, respectively. When readers reload the page, \n    the browser sends along the modification date and etag value for\n    the version it has in its cache. If the page hasn't changed, \n    the server can just return `304 Not Modified` and not have to \n    send the whole page again.\n    \n    This function takes the last-modified date `date` and the ETag `etag`\n    and checks the headers to see if they match. If they do, it returns \n    `True`, or otherwise it raises NotModified error. It also sets \n    `Last-Modified` and `ETag` output headers.\n    " #NEWLINE# try : #NEWLINE# #INDENT# from __builtin__ import set #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# from sets import Set as set #NEWLINE# #UNINDENT# n = set ( [ x . strip ( '" ' ) for x in web . ctx . env . get ( 'HTTP_IF_NONE_MATCH' , '' ) . split ( ',' ) ] ) #NEWLINE# m = net . parsehttpdate ( web . ctx . env . get ( 'HTTP_IF_MODIFIED_SINCE' , '' ) . split ( ';' ) [ 0 ] ) #NEWLINE# validate = False #NEWLINE# if etag : #NEWLINE# #INDENT# if ( ( '*' in n ) or ( etag in n ) ) : #NEWLINE# #INDENT# validate = True #NEWLINE# #UNINDENT# #UNINDENT# if ( date and m ) : #NEWLINE# #INDENT# if ( ( date - datetime . timedelta ( seconds = 1 ) ) <= m ) : #NEWLINE# #INDENT# validate = True #NEWLINE# #UNINDENT# #UNINDENT# if date : #NEWLINE# #INDENT# lastmodified ( date ) #NEWLINE# #UNINDENT# if etag : #NEWLINE# #INDENT# web . header ( 'ETag' , ( ( '"' + etag ) + '"' ) ) #NEWLINE# #UNINDENT# if validate : #NEWLINE# #INDENT# raise web . notmodified ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return True