示例#1
0
def allContent(self, hotels):
    self.response.write('<!DOCTYPE html>\n<html>\n<head>\n<title>Random Hotel</title>\n</head>\n<body>')
    self.response.write('<a href="/about.html">about</a> &nbsp; &nbsp;')
    self.response.write('<a href="/">cached</a> &nbsp; &nbsp;')
    self.response.write('<a href="/no_cache/">not cached</a>\n')
    self.response.write('<h2>' + str(len(hotels)) + ' [New York] Hotels available</h2>')
    self.response.write('(<i>Prices based on 2 adults staying from ' + sig_auth.getCheckIn()
                        + ' to ' + sig_auth.getCheckout() + '.</i>)')

    for hotel in hotels:

        self.response.write('<h3><a href="' + hotel['deepLink'] + '">' + str(hotel['name']) + '</a></h3>\n')

        if 'thumbNailUrl' in hotel and hotel['thumbNailUrl'] is not None and hotel['thumbNailUrl'] != '':
            self.response.write('<img src="http://images.travelnow.com'
                                + hotel['thumbNailUrl'].replace('_t', '_b').replace('-thumb', '')
                                + '" style="float:left; margin-right: 5px;">\n')
        if hotel['lowRate'] == 0 and hotel['highRate'] == 0:
            self.response.write('<i>Not yet available.</i><br>\n')
        else:
            self.response.write('${:.0f} - ${:.0f}<br>\n'.format(hotel['lowRate'],  hotel['highRate']))
            self.response.write(hotel['address1'] + ', ' + hotel['city'] + ', ' + hotel['stateProvinceCode'] + '<br>\n')

        if 'tripAdvisorRatingUrl' in hotel:
            self.response.write('TripAdvisor: <img src="' + hotel['tripAdvisorRatingUrl'] + '">\n')
            self.response.write('from {:d} reviews.'.format(hotel['tripAdvisorReviewCount']))
            self.response.write('<br/>\n')

        self.response.write('<p>' + HTMLParser.HTMLParser().unescape(hotel['shortDescription']) + '</p>\n')
        self.response.write('<br style="clear:both;"/>\n')

        self.response.write('<br><b>Rooms</b><br><br>')

        roomRateDetails = hotel['RoomRateDetailsList']['RoomRateDetails']
        if not isinstance(roomRateDetails, types.ListType):
            roomRateDetails = [roomRateDetails]

        for roomRateDetail in roomRateDetails:
            total = roomRateDetail['RateInfos']['RateInfo']['ChargeableRateInfo']['@total']
            self.response.write('<a href="https://random-hotel.travelnow.com/templates/422557/hotels/'
                                + str(hotel['hotelId'])
                                + '/book?lang=en&currency=USD&standardCheckin=' + sig_auth.getCheckIn()
                                + '&standardCheckout=' + sig_auth.getCheckout()
                                + '&selectedPrice=' + str(total)
                                + '&supplierType=E&rateCode=' + str(roomRateDetail['rateCode'])
                                + '&roomTypeCode=' + str(roomRateDetail['roomTypeCode'])
                                + '&roomsCount=1&rooms[0].adultsCount=2">')
            self.response.write('<b>' + roomRateDetail['roomDescription'] + '</b>')
            self.response.write(' $' + total + '</a><br>')




    self.response.write('\n</body>\n</html>')