def get(self): path = urllib2.unquote(self.request.path) if path == '/service/hotelrating': r = random.random() if r < 0.2: controller.do_calculate_hotel_rating(self.request, self.response); elif r > 0.98: rater.get_all() elif path == '/service/cleanup': controller.do_cleanup(self.request, self.response); else: self.error(404) controller.do_notfound(self.request, self.response)
def do_hotels(request, response, stars = None): ratings = rater.get_all() if stars is not None: hotels = [x for x in place.get_hotels() if int(x.rating) == stars] ratings = [x for x in ratings if any([y for y in hotels if y.name == x.hotel_name])] data = { 'ratings': ratings, 'title': (_("Hotel rating title N stars") % stars) if stars is not None else _("Hotel rating title") } view.to_html(data, 'hotels', request, response)