@newrelic.agent.function_trace()
def document_last_modified(request, document_slug, document_locale):
 adhoc_natural_key = (document_locale, document_slug)
 natural_key_hash = Document.natural_key_hash(adhoc_natural_key)
 cache_key = (DOCUMENT_LAST_MODIFIED_CACHE_KEY_TMPL % natural_key_hash)
 try:
  last_mod = memcache.get(cache_key)
  if (last_mod is None):
   doc = Document.objects.get(locale=document_locale, slug=document_slug)
   last_mod = doc.fill_last_modified_cache()
  return datetime.fromtimestamp(float(last_mod))
 except Document.DoesNotExist:
  return None

@ newrelic . agent . function_trace ( ) def document_last_modified ( request , document_slug , document_locale ) : adhoc_natural_key = ( document_locale , document_slug ) natural_key_hash = Document . natural_key_hash ( adhoc_natural_key ) cache_key = ( DOCUMENT_LAST_MODIFIED_CACHE_KEY_TMPL % natural_key_hash ) try : last_mod = memcache . get ( cache_key ) if ( last_mod is None ) : doc = Document . objects . get ( locale = document_locale , slug = document_slug ) last_mod = doc . fill_last_modified_cache ( ) return datetime . fromtimestamp ( float ( last_mod ) ) except Document . DoesNotExist : return None
utility function to derive the last modified timestamp of a document .