From 79211e7e21061d08b77f9de6bb79d85f8bab4273 Mon Sep 17 00:00:00 2001 From: naath Date: Sun, 30 Mar 2014 12:32:37 +0100 Subject: [PATCH] changed URL formating to use Templates --- familyTree/askQuestion.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/familyTree/askQuestion.py b/familyTree/askQuestion.py index 82684ac..b9c459f 100755 --- a/familyTree/askQuestion.py +++ b/familyTree/askQuestion.py @@ -2,6 +2,10 @@ import sqlite3 import findYear +from string import Template + +global link_Template +link_Template= Template("$text") def run_query(s,t): c = make_cursor() @@ -32,23 +36,18 @@ def print_tagged_query(relationship,s,t,newLine): mine = mine + print_tagged_name(relationship,row,newLine) return mine -def base_url(): - return "http://www.chiark.greenend.org.uk/ucgi/~naath/" def relationship_html(ID,ID2,newLine): if newLine=='
': relationship = common_ancestors(ID,ID2,newLine)[2] - url=base_url()+"ancestors.py?ID="+ID+"&ID2="\ - +str(ID2) - return relationship + ': Common Ancestors'+newLine + script = "ancestors.py?ID="+ID+"&ID2="+str(ID2) + return link_Template.substitute(script = script,text = "Common ancestors") else: return '' def terr_html(terr,newLine): if newLine=='
': - url = base_url()+"territory.py?terr=" - return ''+terr+'' - + return link_Template.substitute(script = "territory.py?terr="+terr, text=terr) else: return terr def name_html(row,html): @@ -57,9 +56,9 @@ def name_html(row,html): elif html=='\n': html=0 if html == 1: - url = base_url()+"person.py?ID=" + str(row[1]) + script = "person.py?ID=" + str(row[1]) name = row[0] - return ""+str(name)+"" + return link_Template.substitute(script = script, text = name) if row[0] == None: return row[1] else: -- 2.30.2