summaryrefslogtreecommitdiff
path: root/index.py
blob: 2b46a3586a590b28575c152f9c5e4bf0d8e1ce00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python

import web
import controller
import model

#
# URL Mappings
#
urls = (
        "/add/?", controller.Add,
        "/edit/(\d+)", controller.Edit,
        "/const/?", controller.Const,
        "/const/(\d+)", controller.Const,
        "/const/add/?", controller.ConstAdd,
        "/const/add/(from)/(\d+)", controller.ConstEdit,
        "/const/edit/(\d+)", controller.ConstEdit,
        "/categories", controller.Cat,
        "/(\d\d\d\d)/(\d\d?)/?", controller.Show,
        "/", controller.Show,
        "/(.*)", controller.FourOhFour
        )
#
# ORM
#
def handle_sql(handler):
    web.ctx.orm = session = model.session
    
    try:
        return handler()
    except web.HTTPError:
       session.commit()
       raise
    except:
        session.rollback()
        raise
    else:
        session.commit()

#
# The App
#
app = web.application(urls, globals())
app.notfound = controller.FourOhFour.catch

# add orm processor
app.add_processor(handle_sql)

# debug for the moment
web.config.debug = True

#
# And go!
if __name__ == "__main__":
    app.run()
='deletions'>-16/+16 2014-04-24dmenu: check for empty instead of ret codeJason A. Donenfeld1-1/+1 2014-04-24tests: sed doesn't like escaped chars on non-gnuJason A. Donenfeld1-1/+1 2014-04-24tests: run from anywhereJason A. Donenfeld13-4/+16 2014-04-24Turns out aliases were a bad idea.Jason A. Donenfeld14-95/+92 2014-04-24Make gpg_opts an array.Jason A. Donenfeld1-12/+12 2014-04-24Shellcheck errors.Jason A. Donenfeld1-6/+6 2014-04-24tests: todo updateJason A. Donenfeld1-25/+0