def handle_plot_request(id, max_age):
 model = models.EmbeddedGraphingQuery.objects.get(id=id)
 now = datetime.datetime.now()
 update_time = (model.last_updated + datetime.timedelta(minutes=int(max_age)))
 if (now > update_time):
  cursor = django.db.connection.cursor()
  query = '\n            UPDATE embedded_graphing_queries\n            SET refresh_time = NOW()\n            WHERE id = %s AND (\n                refresh_time IS NULL OR\n                refresh_time + INTERVAL %s MINUTE < NOW()\n            )\n        '
  cursor.execute(query, (id, _cache_timeout))
  if cursor.rowcount:
   model.cached_png = create_embedded_plot(model, now.ctime())
   model.last_updated = now
   model.refresh_time = None
   model.save()
 return model.cached_png

def handle_plot_request ( id , max_age ) : model = models . EmbeddedGraphingQuery . objects . get ( id = id ) now = datetime . datetime . now ( ) update_time = ( model . last_updated + datetime . timedelta ( minutes = int ( max_age ) ) ) if ( now > update_time ) : cursor = django . db . connection . cursor ( ) query = '\n            UPDATE embedded_graphing_queries\n            SET refresh_time = NOW()\n            WHERE id = %s AND (\n                refresh_time IS NULL OR\n                refresh_time + INTERVAL %s MINUTE < NOW()\n            )\n        ' cursor . execute ( query , ( id , _cache_timeout ) ) if cursor . rowcount : model . cached_png = create_embedded_plot ( model , now . ctime ( ) ) model . last_updated = now model . refresh_time = None model . save ( ) return model . cached_png
given the embedding id of a graph .