#!C:\Program Files\Python27\python.exe # -*- coding: UTF-8 -*- import os, sys, ssl # set path to lib and import sys.path.insert(0, os.path.abspath("../rw_common")) from lib import getRecordSet, ssi_to_tempfile from templating import PageMacro # Get schemalist from DB; page through and retrieve service list schemas = getRecordSet("""SELECT * FROM registry.used_schemas ORDER BY num_datasources DESC""") schemalist = [] for id, ns, num_ds in schemas: rs = getRecordSet("""SELECT name, access_point, count(concept_fk) as num_concepts FROM registry.datasource join registry.datasourceconcept on datasource_fk=datasource_id join registry.concept on concept_fk=concept_id WHERE schema_fk = %i AND active_flag = true GROUP BY datasource_id, name, access_point ORDER BY num_concepts DESC, name""" % id) l = ''.join(['
  • %ix   %s
  • ' % (cnt, ap, name) for name, ap, cnt in rs]) schemalist += [{'id': str(id), 'namespace': ns, 'num_datasources': str(num_ds), 'service_list': l}] # load html template and fill in data tmpl = PageMacro('Content', PageMacro.DELMODE) ssl._create_default_https_context = ssl._create_unverified_context temp = ssi_to_tempfile("https://www.biocase.org/whats_biocase/_services_by_schema.shtml") tmpl.load('Content', temp) tmpl.expand('Content', 'schemalist', schemalist) tmpl.expand('Content', 'schemaoverview', schemalist) # print HTML print "Content-Type: text/html\n" print tmpl os.remove(temp)