]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - www/maps/maps/controllers/location.py
c3e829858e5ea33699bd9c93b50d074c7a56a9f2
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
):
17 if request
.method
== 'POST':
20 # Get the contents of the uploaded files.
21 producers_data
= request
.POST
['producers'].value
.splitlines()
22 consumers_data
= request
.POST
['consumers'].value
.splitlines()
24 producers_csv
= csv
.DictReader(producers_data
)
25 consumers_csv
= csv
.DictReader(consumers_data
)
27 # Create a big json string to pass as a parameter to our
31 for row
in producers_csv
:
32 # Add the producers to the output, one at a time.
33 # But first, insert a 'type' field.
34 row
['type'] = 'producer'
35 json_objects
.append(row
)
37 for row
in consumers_csv
:
38 # Do the same thing for the consumers.
39 row
['type'] = 'consumer'
40 json_objects
.append(row
)
42 c
.json
= json
.dumps(json_objects
)
44 return render('/location/index.mako')