Search of region

This commit is contained in:
Stephane Bortzmeyer 2023-08-02 17:52:44 +02:00
parent e5026f8c7a
commit ccaeb5240e
2 changed files with 6 additions and 0 deletions

View File

@ -69,6 +69,9 @@ def application(environ, start_response):
elif form["what"] == "script":
sql = "SELECT code,added,comments FROM Scripts WHERE code = %s"
term = form["string"].capitalize()
elif form["what"] == "region":
sql = "SELECT code,added,comments FROM Regions WHERE code = %s"
term = form["string"].upper()
else:
status = "400 Invalid request"
msg = "Unknown search category \"%s\"\r\n" % form["what"]
@ -96,6 +99,8 @@ def application(environ, start_response):
sql = "SELECT Languages.code, Descriptions.description FROM Languages,Descriptions_Languages,Descriptions WHERE Descriptions_Languages.description = Descriptions.id AND Descriptions_Languages.lang = Languages.code AND position(%s in lower(Descriptions.description)) > 0;"
elif form["what"] == "script":
sql = "SELECT Scripts.code, Descriptions.description FROM Scripts,Descriptions_Scripts,Descriptions WHERE Descriptions_Scripts.description = Descriptions.id AND Descriptions_Scripts.script = Scripts.code AND position(%s in lower(Descriptions.description)) > 0;"
elif form["what"] == "region":
sql = "SELECT Regions.code, Descriptions.description FROM Regions,Descriptions_Regions,Descriptions WHERE Descriptions_Regions.description = Descriptions.id AND Descriptions_Regions.region = Regions.code AND position(%s in lower(Descriptions.description)) > 0;"
cursor.execute(sql, (form["string"], ))
found = False
with tag("h1"):

View File

@ -6,6 +6,7 @@
<p>Search in: <select name="what">
<option value="language">Languages</option>
<option value="script">Scripts</option>
<option value="script">Regions</option>
</select></p>
<p><input type="submit" value="Search"/></p>
</form>