#!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 LEFT JOIN registry.datasource d ON provider_id=provider_fk WHERE (protocol_fk='biocase' and active_flag) 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].replace('&', '&') if row[1] else '(unnamend)', 'town': row[2], 'country': row[3], 'lat': str(row[4]), 'lon': str(row[5]), 'url': row[6]} for row in rs]) tmpl['network'] = 'GBIF' # print HTML print "Content-Type: text/xml\n" print tmpl