def gethist():
 codetbl = db.code
 acid = request.vars.acid
 if request.vars.sid:
  sid = request.vars.sid
  course_id = db((db.auth_user.username == sid)).select(db.auth_user.course_id).first().course_id
 elif auth.user:
  sid = auth.user.username
  course_id = auth.user.course_id
 else:
  sid = None
  course_id = None
 res = {}
 if sid:
  query = ((((codetbl.sid == sid) & (codetbl.acid == acid)) & (codetbl.course_id == course_id)) & (codetbl.timestamp != None))
  res['acid'] = acid
  res['sid'] = sid
  r = db(query).select(orderby=codetbl.id)
  res['history'] = [row.code for row in r]
  res['timestamps'] = [row.timestamp.isoformat() for row in r]
 response.headers['content-type'] = 'application/json'
 return json.dumps(res)

def gethist ( ) : codetbl = db . code acid = request . vars . acid if request . vars . sid : sid = request . vars . sid course_id = db ( ( db . auth_user . username == sid ) ) . select ( db . auth_user . course_id ) . first ( ) . course_id elif auth . user : sid = auth . user . username course_id = auth . user . course_id else : sid = None course_id = None res = { } if sid : query = ( ( ( ( codetbl . sid == sid ) & ( codetbl . acid == acid ) ) & ( codetbl . course_id == course_id ) ) & ( codetbl . timestamp != None ) ) res [ 'acid' ] = acid res [ 'sid' ] = sid r = db ( query ) . select ( orderby = codetbl . id ) res [ 'history' ] = [ row . code for row in r ] res [ 'timestamps' ] = [ row . timestamp . isoformat ( ) for row in r ] response . headers [ 'content-type' ] = 'application/json' return json . dumps ( res )
return the history of saved code by this user for a particular acid .