import cgi import re form = cgi.FieldStorage() subj = form.getvalue('subj') s = Storage() def is_alpha(s): p = '^[a-zA-Z\s]*$' if re.match(p, s): return True return False if subj.isdigit(): result = s.get_id(subj) elif not is_alpha(subj): result = s.search_writing(subj, 10) else: result = s.search_meaning(subj, 10) html = '' html += '<table class="result">' if result: for item in result: html += '<tr>' html += '<td class="main">' if item.writings:
from lib.storage import Storage import cgi form = cgi.FieldStorage() id = form.getvalue('id') s = Storage() result = s.get_id(id) result = result[0] html = "" html += "Writing:" html += "<ul>" for w in result.writings: html += "<li>%s</li>" % w.content html += "</ul>" html += "Reading:" html += "<ul>" for r in result.readings: html += "<li>%s</li>" % r.content html += "</ul>" html += "Meaning:" html += "<ul>" for m in result.meanings: #if m.parts: # html += "<li>%s</li>" % '; '.join([p.content for p in m.parts])