# Search ---------------------------------------------------
-def do_fullsearch(needle):
+def handle_fullsearch(needle):
send_title(None, 'Full text search for "%s"' % (needle))
needle_re = re.compile(needle, re.IGNORECASE)
print_search_stats(len(hits), len(all_pages))
-def do_titlesearch(needle):
+def handle_titlesearch(needle):
# TODO: check needle is legal -- but probably we can just accept any RE
send_title(None, "Title search for \"" + needle + '"')
def print_search_stats(hits, searched):
print "<p>%d hits out of %d pages searched.</p>" % (hits, searched)
-def do_raw(pagename):
+def handle_raw(pagename):
Page(pagename).send_raw()
-def do_edit(pagename):
+def handle_edit(pagename):
pg = Page(pagename)
if 'save' in form:
if form['file'].value:
pg.msg_text = 'Editing canceled'
pg.msg_type = 'notice'
pg.send_page()
- else:
+ else: # preview or edit
text = None
if 'preview' in form:
text = form['savetext'].value
macro = globals().get('_macro_' + name)
if macro:
- return apply(macro, (name, descr))
+ return macro(name, descr)
elif img_re.match(name):
name = relative_url(name)
# The "extthumb" nonsense works around a limitation of the HTML block model
def replace(self, match):
for type, hit in match.groupdict().items():
if hit:
- return apply(getattr(self, '_' + type + '_repl'), (hit,))
+ return getattr(self, '_' + type + '_repl')(hit)
else:
raise "Can't handle match " + `match`
try:
execfile("geekigeeki.conf.py")
form = cgi.FieldStorage()
- handlers = {
- 'fullsearch': do_fullsearch,
- 'titlesearch': do_titlesearch,
- 'edit': do_edit,
- 'raw': do_raw,
- }
-
- for cmd in handlers.keys():
- if cmd in form:
- apply(handlers[cmd], (form[cmd].value,))
+
+ for cmd in form:
+ handler = globals().get('handle_' + cmd)
+ if handler:
+ handler(form[cmd].value)
break
else:
path_info = environ.get('PATH_INFO', '')
else:
print "Status: 404 Not Found"
send_title(None, msg_text='Can\'t work out query: ' + query)
+ send_footer(None)
except Exception:
import traceback
msg_text = traceback.format_exc()