def getprog():
 codetbl = db.code
 acid = request.vars.acid
 sid = request.vars.sid
 if sid:
  query = (((codetbl.sid == sid) & (codetbl.acid == acid)) & (codetbl.timestamp != None))
 elif auth.user:
  query = (((codetbl.sid == auth.user.username) & (codetbl.acid == acid)) & (codetbl.timestamp != None))
 else:
  query = None
 res = {}
 if query:
  result = db(query)
  res['acid'] = acid
  if (not result.isempty()):
   r = result.select(orderby=codetbl.id).last().code
   res['source'] = r
   if sid:
    res['sid'] = sid
  else:
   logging.debug(('Did not find anything to load for %s' % sid))
 response.headers['content-type'] = 'application/json'
 return json.dumps([res])

def getprog ( ) : codetbl = db . code acid = request . vars . acid sid = request . vars . sid if sid : query = ( ( ( codetbl . sid == sid ) & ( codetbl . acid == acid ) ) & ( codetbl . timestamp != None ) ) elif auth . user : query = ( ( ( codetbl . sid == auth . user . username ) & ( codetbl . acid == acid ) ) & ( codetbl . timestamp != None ) ) else : query = None res = { } if query : result = db ( query ) res [ 'acid' ] = acid if ( not result . isempty ( ) ) : r = result . select ( orderby = codetbl . id ) . last ( ) . code res [ 'source' ] = r if sid : res [ 'sid' ] = sid else : logging . debug ( ( 'Did not find anything to load for %s' % sid ) ) response . headers [ 'content-type' ] = 'application/json' return json . dumps ( [ res ] )
return the program code for a particular acid .