Beispiel #1
0
    def get(self):
        vlillef = Vlille()
        vlillef.load_stations()

        stations = []
        for station in vlillef.stations:
            stations.append(StationData(key_name=str(station.id),
                                        id_vlille=station.id,
                                        name=station.name))

        db.delete(StationData.all())
        db.put(stations)

        self.response.out.write("stations : %i" % len(vlillef.stations))
Beispiel #2
0
    def _match_station(self):
        m = self.reg.match(self.request.path)
        if not m:
            return None

        station_id = m.group(1)

        station = memcache.get("station-" + station_id)

        if station is None:
            station_data = memcache.get("station-db-" + station_id)

            if station_data is None:
                station_data = StationData.get_by_key_name(station_id)
                memcache.set("station-db-" + station_id, station_data, time=TIMEOUT_LONG)

            station = Station(id=station_id)
            if station_data is None:
                logging.error("oh noes - station_id {0} is None !".format(station_id))
                return None
            station.name = station_data.name
            station.refresh()
            memcache.set("station-" + station_id, station, time=TIMEOUT_STATION)

        return station
Beispiel #3
0
    def get(self):
        stations = memcache.get("stations")

        if stations is None:
            logging.info("- rebuild liste des stations")
            stations = StationData.all()
            stations_light = []
            for station in stations:
                stations_light.append({'id_vlille': station.id_vlille, 'name': station.name})

            memcache.set("stations", stations_light, time=TIMEOUT_LONG)

        return self._template({'stations': stations}, "index_stations.html")