From 1ce67953dfe84ebc618006d2508660043f02b2b2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 15 Mar 2023 09:33:20 -0500 Subject: [PATCH] Let providers do DB connection setup for web API --- tailbone/webapi.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tailbone/webapi.py b/tailbone/webapi.py index b623bd70..a437f0c3 100644 --- a/tailbone/webapi.py +++ b/tailbone/webapi.py @@ -32,6 +32,7 @@ from pyramid.authentication import SessionAuthenticationPolicy from tailbone import app from tailbone.auth import TailboneAuthorizationPolicy +from tailbone.providers import get_all_providers def make_rattail_config(settings): @@ -46,6 +47,7 @@ def make_pyramid_config(settings): """ Make a Pyramid config object from the given settings. """ + rattail_config = settings['rattail_config'] pyramid_config = Configurator(settings=settings, root_factory=app.Root) # configure user authorization / authentication @@ -77,6 +79,13 @@ def make_pyramid_config(settings): else: pyramid_config.include('pyramid_retry') + # fetch all tailbone providers + providers = get_all_providers(rattail_config) + for provider in providers.values(): + + # configure DB sessions associated with transaction manager + provider.configure_db_sessions(rattail_config, pyramid_config) + # add some permissions magic pyramid_config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group') pyramid_config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission')