summaryrefslogtreecommitdiff
path: root/index.py
blob: d9e2e7d3ec9bc33f7595a80a072d2bbd742e8895 (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
#!/usr/bin/python

import web
import controller
import model

#
# URL Mappings
#
urls = (
        "/r/(.*)", controller.Redirect,
        "/(.*)", controller.Page
        )

#
# 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

# add orm processor
app.add_processor(handle_sql)

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

#
# And go!
if __name__ == "__main__":
    app.run()