json:add get_stats method

This commit is contained in:
Martijn Voncken 2008-06-30 17:40:28 +00:00
parent 6f87ba0646
commit e2bc3dbd48
1 changed files with 26 additions and 8 deletions

View File

@ -87,18 +87,36 @@ def self_url(**kwargs):
return config["base"] + changequery(**kwargs)
def do_redirect():
import render
"""go to /index unless the redir var is set."""
vars = web.input(redir=None)
"""for redirects after a POST"""
vars = web.input(redir = None)
ck = cookies()
url_vars = {}
if vars.redir:
w_seeother(vars.redir) #redir variable contains base
return
#test-alt-home
if hasattr(render,"home"):
return render.home()
#default:
seeother('/index')
#for the filters:
if ("order" in ck and "sort" in ck):
url_vars.update({'sort':ck['sort'] ,'order':ck['order'] })
organize = False
try:
organize = ('Organize' in sclient.get_enabled_plugins())
except:
pass
if organize:
#todo:DRY
if ("state" in ck) and ck['state']:
url_vars['state'] = ck['state']
if ("tracker" in ck) and ck['tracker']:
url_vars['tracker'] = ck['tracker']
if ("keyword" in ck) and ck['keyword']:
url_vars['keyword'] = ck['keyword']
#redirect.
w_seeother(url("/index", **url_vars))
def getcookie(key, default = None):
"because i'm too lazy to type 3 lines for something this simple"