
Story: 2008529 Task: 41688 Signed-off-by: Bin Yang <bin.yang@windriver.com> Change-Id: Ib276520605cc624a9976f804a1721ba2c5909403
30 lines
812 B
Python
30 lines
812 B
Python
from pecan import make_app
|
|
from pecan.hooks import TransactionHook
|
|
from pecan import conf
|
|
|
|
from sidecar.repository.dbcontext_default import init_default_dbcontext, defaults
|
|
from sidecar.model import jsonify
|
|
|
|
def setup_app(config):
|
|
|
|
# important to register jsonify for models
|
|
jsonify.__init__()
|
|
|
|
default_dbcontext = init_default_dbcontext(conf.sqlalchemy)
|
|
app_conf = dict(config.app)
|
|
|
|
return make_app(
|
|
app_conf.pop('root'),
|
|
logging=getattr(config, 'logging', {}),
|
|
hooks=[
|
|
TransactionHook(
|
|
default_dbcontext.start,
|
|
default_dbcontext.start_read_only,
|
|
default_dbcontext.commit,
|
|
default_dbcontext.rollback,
|
|
default_dbcontext.clear
|
|
)
|
|
],
|
|
**app_conf
|
|
)
|