]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - 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
):
15 return render('/location/index.mako')
19 if request
.method
!= 'POST':
20 return 'You should have posted some data.'
22 # Get the contents of the uploaded files.
23 producers_data
= request
.POST
['producers'].value
.splitlines()
24 consumers_data
= request
.POST
['consumers'].value
.splitlines()
26 producers_csv
= csv
.DictReader(producers_data
)
27 consumers_csv
= csv
.DictReader(consumers_data
)
29 # Create a big json string to pass as a parameter to our
33 for row
in producers_csv
:
34 # Add the producers to the output, one at a time.
35 # But first, insert a 'type' field.
36 row
['type'] = 'producer'
37 json_objects
.append(row
)
39 for row
in consumers_csv
:
40 # Do the same thing for the consumers.
41 row
['type'] = 'consumer'
42 json_objects
.append(row
)
44 c
.json
= json
.dumps(json_objects
)
45 c
.js
= render('javascript/routing.mako')
47 return render('location/route.mako')