def tropo():
 from tropo import Tropo, Session
 try:
  s = Session(request.body.read())
  t = Tropo()
  try:
   row_id = s.parameters['row_id']
   table = s3db.msg_tropo_scratch
   query = (table.row_id == row_id)
   row = db(query).select().first()
   t.call(to=row.recipient, network=row.network)
   t.say(row.message)
   outbox = s3db.msg_outbox
   db((outbox.id == row.row_id)).update(status=2)
   db(query).delete()
   return t.RenderJson()
  except:
   try:
    message = s.initialText
    uuid = s.id
    recipient = s.to['id']
    try:
     fromaddress = s.fromaddress['id']
    except:
     fromaddress = ''
    reply = msg.parse_message(message)
    t.say([reply])
    return t.RenderJson()
   except:
    raise HTTP(501)
 except:
  pass

def tropo ( ) : from tropo import Tropo , Session try : s = Session ( request . body . read ( ) ) t = Tropo ( ) try : row_id = s . parameters [ 'row_id' ] table = s3db . msg_tropo_scratch query = ( table . row_id == row_id ) row = db ( query ) . select ( ) . first ( ) t . call ( to = row . recipient , network = row . network ) t . say ( row . message ) outbox = s3db . msg_outbox db ( ( outbox . id == row . row_id ) ) . update ( status = 2 ) db ( query ) . delete ( ) return t . RenderJson ( ) except : try : message = s . initialText uuid = s . id recipient = s . to [ 'id' ] try : fromaddress = s . fromaddress [ 'id' ] except : fromaddress = '' reply = msg . parse_message ( message ) t . say ( [ reply ] ) return t . RenderJson ( ) except : raise HTTP ( 501 ) except : pass
receive a json post from the tropo webapi @see: URL .