-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathhooks.py
More file actions
27 lines (19 loc) · 772 Bytes
/
hooks.py
File metadata and controls
27 lines (19 loc) · 772 Bytes
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
from pecan import hooks
from billingstack.openstack.common import cfg
from billingstack.openstack.common import log
from billingstack import storage
class ConfigHook(hooks.PecanHook):
"""Attach the configuration object to the request
so controllers can get to it.
"""
def before(self, state):
state.request.cfg = cfg.CONF
class DBHook(hooks.PecanHook):
def before(self, state):
storage_engine = storage.get_engine(
state.request.cfg['service:api'].storage_driver)
state.request.storage_engine = storage_engine
state.request.storage_conn = storage_engine.get_connection()
# def after(self, state):
# print 'method:', state.request.method
# print 'response:', state.response.status