Example #1
0
 def api1_types(self, req):
     s = select([Jurisdiction.type_uri], distinct=True).order_by(Jurisdiction.type_uri)
     conn = engine.connect()
     results = [row.type_uri for row in conn.execute(s)]
     return Response(
         dumps(results),
         content_type='application/json')
Example #2
0
 def api1_kml(self, req):
     assert req.path_info_pop() == 'api1'
     assert req.path_info_pop() == 'kml'
     id = int(req.path_info.lstrip('/'))
     s = select([Jurisdiction.__table__], Jurisdiction.id==id)
     conn = engine.connect()
     s = list(conn.execute(s))[0]
     kml_inner = session.scalar(s.geom.kml)
     kml = KML_TEMPLATE.substitute(
         name=cgi.escape(s.name),
         uri=cgi.escape(s.uri),
         polygons=kml_inner)
     return Response(
         kml,
         content_type='application/vnd.google-earth.kml+xml')