def calc_last_modified(request, *args, **kwargs):
 assert ('cache_name' in kwargs), 'Must specify cache_name as a keyword arg.'
 try:
  cache = get_cache(kwargs['cache_name'])
  assert (isinstance(cache, FileBasedCache) or isinstance(cache, LocMemCache)), 'requires file-based or mem-based cache.'
 except InvalidCacheBackendError:
  return None
 key = django_get_cache_key(request, cache=cache)
 if ((key is None) or (not cache.has_key(key))):
  return None
 if isinstance(cache, FileBasedCache):
  fname = cache._key_to_file(cache.make_key(key))
  if (not os.path.exists(fname)):
   return None
  last_modified = datetime.datetime.fromtimestamp(os.path.getmtime(fname))
 elif isinstance(cache, LocMemCache):
  creation_time = (cache._expire_info[cache.make_key(key)] - settings.CACHE_TIME)
  last_modified = datetime.datetime.fromtimestamp(creation_time)
 return last_modified

def calc_last_modified ( request , * args , ** kwargs ) : assert ( 'cache_name' in kwargs ) , 'Must specify cache_name as a keyword arg.' try : cache = get_cache ( kwargs [ 'cache_name' ] ) assert ( isinstance ( cache , FileBasedCache ) or isinstance ( cache , LocMemCache ) ) , 'requires file-based or mem-based cache.' except InvalidCacheBackendError : return None key = django_get_cache_key ( request , cache = cache ) if ( ( key is None ) or ( not cache . has_key ( key ) ) ) : return None if isinstance ( cache , FileBasedCache ) : fname = cache . _key_to_file ( cache . make_key ( key ) ) if ( not os . path . exists ( fname ) ) : return None last_modified = datetime . datetime . fromtimestamp ( os . path . getmtime ( fname ) ) elif isinstance ( cache , LocMemCache ) : creation_time = ( cache . _expire_info [ cache . make_key ( key ) ] - settings . CACHE_TIME ) last_modified = datetime . datetime . fromtimestamp ( creation_time ) return last_modified
returns the files modified time as the last-modified date .