def _add_urls_to_results(search): gets = list() length = len(search['results']) for i in xrange(length): gets.append(Place.all().filter('google_places_id =', search['results'][i]['id']).run()) for i in xrange(length): place = gets[i] try: place = place.next() search['results'][i].update({'_url': place.get_absolute_url()}) except StopIteration: # no existe, devolvemos una url 'generica' search['results'][i].update({'_url': '/place/gref/%s' % search['results'][i]['reference']}) return search
def _add_urls_to_results(search): gets = list() length = len(search['results']) for i in xrange(length): gets.append(Place.all().filter('google_places_id =', search['results'][i]['id']).run()) for i in xrange(length): place = gets[i] try: place = place.next() search['results'][i].update({'_url': place.get_absolute_url()}) except StopIteration: # no existe, devolvemos una url 'generica' search['results'][i].update({ '_url': '/place/gref/%s' % search['results'][i]['reference'] }) return search