def load_graph(): key = 'router_graph' data = memcache.get(key) #@UndefinedVariable if data != None: return data subway_dict = json.loads(param.get('subway')) graph = StationGraph() graph.steps = [Station(x['name'], x['name_rus'], x['lat'], x['lng'], x['transport'], x['line']) for x in subway_dict['stations']] graph.links = [StationLink(x['from_station'], x['to_station'], x['duration']) for x in subway_dict['links']] memcache.add(key, graph, 60*60) #@UndefinedVariable return graph
def do_calculate_hotel_rating(request, response): current_index_str = param.get('current_hotel_index') if current_index_str == None: current_index = 0 else: current_index = int(current_index_str) + 1 hotels = place.get_hotels() if len(hotels) <= current_index: current_index = 0 hotel = hotels[current_index] rater.get(hotel) param.add('current_hotel_index', str(current_index)) response.out.write('Processed the rating of hotel ' + hotel.name) logging.info('Processed the rating of hotel ' + hotel.name)