def is_resource_modified(environ, etag=None, data=None, last_modified=None):
 if ((etag is None) and (data is not None)):
  etag = generate_etag(data)
 elif (data is not None):
  raise TypeError('both data and etag given')
 if (environ['REQUEST_METHOD'] not in ('GET', 'HEAD')):
  return False
 unmodified = False
 if isinstance(last_modified, basestring):
  last_modified = parse_date(last_modified)
 if (last_modified is not None):
  last_modified = last_modified.replace(microsecond=0)
 modified_since = parse_date(environ.get('HTTP_IF_MODIFIED_SINCE'))
 if (modified_since and last_modified and (last_modified <= modified_since)):
  unmodified = True
 if etag:
  if_none_match = parse_etags(environ.get('HTTP_IF_NONE_MATCH'))
  if if_none_match:
   unmodified = if_none_match.contains_raw(etag)
 return (not unmodified)

def is_resource_modified ( environ , etag = None , data = None , last_modified = None ) : if ( ( etag is None ) and ( data is not None ) ) : etag = generate_etag ( data ) elif ( data is not None ) : raise TypeError ( 'both data and etag given' ) if ( environ [ 'REQUEST_METHOD' ] not in ( 'GET' , 'HEAD' ) ) : return False unmodified = False if isinstance ( last_modified , basestring ) : last_modified = parse_date ( last_modified ) if ( last_modified is not None ) : last_modified = last_modified . replace ( microsecond = 0 ) modified_since = parse_date ( environ . get ( 'HTTP_IF_MODIFIED_SINCE' ) ) if ( modified_since and last_modified and ( last_modified <= modified_since ) ) : unmodified = True if etag : if_none_match = parse_etags ( environ . get ( 'HTTP_IF_NONE_MATCH' ) ) if if_none_match : unmodified = if_none_match . contains_raw ( etag ) return ( not unmodified )
convenience method for conditional requests .