def agencies_and_routes(self): all_routes = {} for agency in Agency.get_or_fetch().iteritems(): agency_tag = agency[0] agency_model_dict = agency[1].to_dict() agency_model_dict.setdefault("routes", []).append(Route.get_or_fetch(agency_tag)) all_routes[agency_tag] = agency_model_dict return formatter.JSON(all_routes)
def post(self): message = xmpp.Message(self.request.POST) if message.body == "routes": r = Route.get_or_fetch("mbta") message.reply(", ".join(r.keys())) elif message.body == "@home": e = Estimation.get_or_fetch("mbta", "747", "747_0_var0", "1807") message.reply(formatter.JSON(e)) elif message.body == "@office": e = Estimation.get_or_fetch("mbta", "747", "747_0_var1", "2231_1") message.reply(formatter.JSON(e)) else: message.reply("...")
def routes(self, agency_tag): return formatter.JSON(Route.get_or_fetch(agency_tag))