Using the pyramid-cookiecutter-alchemy setup you can access config data at config time using a pattern like this:
from transaction import TransactionManager from myapp.models import get_tm_session def main(global_config, **settings): config = Configurator(settings=settings) config.include('myapp.models') tm = TransactionManager(explicit=True) with tm: dbsession = get_tm_session(config.registry['dbsession_factory'], tm) ... # do queries and stuff return config.make_wsgi_app() This will properly handle the lifecycle of a session for you, same as when serving a request. Be sure if you keep any objects around that you expunge them from the session and re-attach/merge them into any session where you use them.. ORM objects are only valid on the dbsession they were loaded from. - Michael On Mon, Apr 2, 2018 at 11:59 AM, Zsolt Ero <zsolt....@gmail.com> wrote: > OK, I agree with that. Still, storing config values in the database is > a common pattern for medium to large web apps, so it at least makes > sense to have some kind of resource about how to do it. I hope that if > nothing else at least this thread will be useful for someone in the future. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To post to this group, send email to pylons-discuss@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/pylons-discuss/CAKw-smBuH5hKGpNgs-6dYkNiAU% > 3DGGUUOF7aLHAzHe0AE25T7qg%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAKdhhwGoPbgM7gDWBLxdanT%3DhcJQR8sT01E2xwWFxw1zxpCD1A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.