def plan_feed(request):
    feed = loader.get_template('plan_feed.xml')
    # MAP_SERVER = ''
    # MAP_SERVER_NS = 'pmp'
    plans = Plan.objects.all().order_by('-edited')[0:10]
    geolevel = plans[0].legislative_body.get_geolevels()[0]
    extent = geolevel.geounit_set.collect().extent
    if extent[2] - extent[0] > extent[3] - extent[1]:
        # wider maps
        width = 500
        height = int(500 * (extent[3]-extent[1]) / (extent[2]-extent[0]))
    else:
        # taller maps
        width = int(500 * (extent[2]-extent[0]) / (extent[3]-extent[1]))
        height = 500
    mapserver = settings.MAP_SERVER if settings.MAP_SERVER != '' else request.META['SERVER_NAME']
    context = {
        'plans': plans,
        'mapserver': mapserver,
        'mapserver_ns': settings.MAP_SERVER_NS,
        'extent': extent,
        'width': width,
        'height': height
    }
    xml = feed.render(DjangoContext(context))

    return HttpResponse(xml, mimetype='application/atom+xml')
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/views.py/plan_feed/original