]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - www/maps/maps/controllers/location.py
5 from pylons
import request
, response
, session
, tmpl_context
as c
6 from pylons
.controllers
.util
import abort
, redirect_to
8 from maps
.lib
.base
import BaseController
, render
10 log
= logging
.getLogger(__name__
)
12 class LocationController(BaseController
):
18 return render('/location/index.mako')
22 if request
.method
!= 'POST':
23 return 'You should have posted some data.'
25 if (c
.postback_url
== None):
26 c
.postback_url
= '/directions/json_to_kml'
28 # Get the contents of the uploaded files.
29 producers_data
= request
.POST
['producers'].value
.splitlines()
30 consumers_data
= request
.POST
['consumers'].value
.splitlines()
32 producers_csv
= csv
.DictReader(producers_data
)
33 consumers_csv
= csv
.DictReader(consumers_data
)
35 # Create a big json string to pass as a parameter to our
39 for row
in producers_csv
:
40 # Add the producers to the output, one at a time.
41 # But first, insert a 'type' field.
42 row
['type'] = 'producer'
43 json_objects
.append(row
)
45 for row
in consumers_csv
:
46 # Do the same thing for the consumers.
47 row
['type'] = 'consumer'
48 json_objects
.append(row
)
50 c
.json
= json
.dumps(json_objects
)
51 c
.js
= render('javascript/routing.mako')
53 return render('location/route.mako')
56 c
.postback_url
= '/directions/distances'