Exemple #1
0
class EstadoActualHandler(RequestHandler):

    def initialize(self):
        self.hist = HistorialPrograma(self.application.db)
        self.progs = Programa(self.application.db)

    def get(self):
        last_hist = self.hist.getmax()
        if last_hist is not None:
            prog = self.progs.get({'id': str(last_hist['programa_id'])})
            data = {
                'titulo': prog['titulo'],
                'desde': last_hist['created'],
            }
        else:
            data = {
                'titulo': False,
                'desde': False,
            }
        self.write(escape.json_encode(data))
        self.set_header("Content-Type", "application/json")