author | Tero Marttila <terom@paivola.fi> |
Sat, 26 Jan 2013 17:52:40 +0200 | |
changeset 178 | f9f5e669bace |
parent 158 | 3ff66d4f401c |
permissions | -rw-r--r-- |
3 | 1 |
# encoding: utf-8 |
178
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
2 |
import pvl.web |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
3 |
from pvl.web import html, urls |
7
7baf4cccb4a9
move Index to urls; fix self.url(sort=...)
Tero Marttila <terom@paivola.fi>
parents:
6
diff
changeset
|
4 |
|
178
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
5 |
import logging; log = logging.getLogger('pvl.verkko.web') |
4 | 6 |
|
178
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
7 |
class DatabaseHandler (pvl.web.Handler) : |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
8 |
""" |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
9 |
Request handler with pvl.verkko.Database session |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
10 |
""" |
0 | 11 |
|
7
7baf4cccb4a9
move Index to urls; fix self.url(sort=...)
Tero Marttila <terom@paivola.fi>
parents:
6
diff
changeset
|
12 |
def __init__ (self, app, request, urls, params) : |
178
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
13 |
super(DatabaseHandler, self).__init__(app, request, urls, params) |
3 | 14 |
|
16
51509b5ce1c0
request per session, move to postgres, rename columns, fixup state/name/error handling in updates
Tero Marttila <terom@paivola.fi>
parents:
7
diff
changeset
|
15 |
# new ORM session per request |
51509b5ce1c0
request per session, move to postgres, rename columns, fixup state/name/error handling in updates
Tero Marttila <terom@paivola.fi>
parents:
7
diff
changeset
|
16 |
self.db = app.db.session() |
6 | 17 |
|
26
589249097230
hosts: convert realtime list into table; breaks animations :(
Tero Marttila <terom@paivola.fi>
parents:
24
diff
changeset
|
18 |
def cleanup (self) : |
589249097230
hosts: convert realtime list into table; breaks animations :(
Tero Marttila <terom@paivola.fi>
parents:
24
diff
changeset
|
19 |
""" |
151
8a9f01036091
split pvl.web from pvl.verkko, rename test.py -> pvl.verkko-dhcp
Tero Marttila <terom@paivola.fi>
parents:
26
diff
changeset
|
20 |
After request processing. |
26
589249097230
hosts: convert realtime list into table; breaks animations :(
Tero Marttila <terom@paivola.fi>
parents:
24
diff
changeset
|
21 |
""" |
589249097230
hosts: convert realtime list into table; breaks animations :(
Tero Marttila <terom@paivola.fi>
parents:
24
diff
changeset
|
22 |
|
589249097230
hosts: convert realtime list into table; breaks animations :(
Tero Marttila <terom@paivola.fi>
parents:
24
diff
changeset
|
23 |
# XXX: SQLAlchemy doesn't automatically close these...? |
589249097230
hosts: convert realtime list into table; breaks animations :(
Tero Marttila <terom@paivola.fi>
parents:
24
diff
changeset
|
24 |
self.db.close() |
178
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
25 |
|
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
26 |
class Application (pvl.web.Application) : |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
27 |
""" |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
28 |
Application with pvl.verkko.Database |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
29 |
""" |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
30 |
|
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
31 |
def __init__ (self, db, **opts) : |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
32 |
""" |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
33 |
db - pvl.verkko.Database |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
34 |
""" |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
35 |
|
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
36 |
super(Application, self).__init__(**opts) |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
37 |
|
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
38 |
self.db = db |
f9f5e669bace
pvl.verkko: refactor into dhcp -> hosts -> web+db modules, reworking index page
Tero Marttila <terom@paivola.fi>
parents:
158
diff
changeset
|
39 |