def handle_GET(self, request, context, control_number):
        
        # Build a map of all the libraries that have this book, with markers
        # corresponding to colours
        
        user_location = request.session.get('geolocation:location')
        
        points = []
        point_libraries = []
        lbs = context['item'].libraries.items()
        
        for library, books in lbs:
            library.entity = library.get_entity()

        if user_location:
            lbs = sorted(lbs, key=lambda (l,b): (haversine(user_location, l.entity.location)
                if l.entity and l.entity.location else float('inf')))

        for library, books in lbs:
            if library.entity != None and library.entity.location != None:
                colour = AVAIL_COLORS[max(b['availability'] for b in books)]
                points.append((library.entity.location[0],
                               library.entity.location[1],
                               colour,
                               library.entity.title))
                point_libraries.append(library)
        
        if len(points) > 0:
            context['map'] = Map(
                centre_point = (user_location[0], user_location[1], 'green', '')
                                if user_location != None else None,
                points = points,
                min_points = 0 if context['zoom'] else len(points),
                zoom = context['zoom'],
                width = request.map_width,
                height = request.map_height,
            )
            
            # Yes, this is weird. fit_to_map() groups libraries with the same
            # location so here we add a marker_number to each library to display
            # in the template.
            lib_iter = iter(point_libraries)
            for i, (a,b) in enumerate(context['map'].points):
                for j in range(len(b)):
                    lib_iter.next().marker_number = i + 1
        
        context.update({
            'sorted_libraries': lbs,
        })
        
        return self.render(request, context, 'library/item_detail')
dataset/ETHPy150Open mollyproject/mollyproject/molly/apps/library/views.py/ItemDetailView.handle_GET/original