#!C:\Program Files\Python27\python.exe # -*- coding: UTF-8 -*- import os, sys # set path to lib and import sys.path.insert(0, os.path.abspath("../rw_common")) from lib import getRecordSet from templating import PageMacro # Get list from DB rs = getRecordSet(""" SELECT p.provider_id, p.name, p.town, p.country, p.latitude, p.longitude, p.home_url FROM registry.provider p WHERE avh AND latitude is not null and longitude is not null GROUP BY p.provider_id, p.name, p.town, p.country, p.latitude, p.longitude, p.home_url""") # load html template and fill in data tmpl = PageMacro('Content', PageMacro.DELMODE) tmpl.load('Content', '_layer.kml') tmpl.expand('Content', 'providerlist', [{'id': str(row[0]), 'name': row[1], 'town': row[2], 'country': row[3], 'lat': str(row[4]), 'lon': str(row[5]), 'url': row[6]} for row in rs]) tmpl['network'] = 'AVH' # print HTML print "Content-Type: text/xml\n" print tmpl