The magic lines you are looking for are https://github.com/TurboGears/tg2devtools/blob/master/devtools/gearbox/tgshell.py#L50-L54
Performing a request to /_test_vars makes a fake request that forces application initialization and loads the TurboGears context in memory, so you will have tg.config, tg.request and so on available. Much of what is explained in http://turbogears.readthedocs.org/en/latest/turbogears/testing.html#testing-outside-controllers also applies perfectly to writing scripts (like gearbox commands) that use TG. On Thu, Jan 28, 2016 at 9:35 AM, Bastien Sevajol <[email protected]> wrote: > Hi, > > I can't access to app configuration inside my command: > > # -*- coding: utf-8 -*- > from gearbox.command import Command > from tg import config > > class CrawlCommand(Command): > def take_action(self, parsed_args): > print(config.get('sqlalchemy.url')) > > produce: > > > gearbox crawl > None > > I would like be able to read app config like in tgshell: > > > gearbox tgshell > >>> from tg import config > >>> config.get('sqlalchemy.url') > 'postgresql://pyjobs:pyjobs@localhost/pyjobs' > > How to load environnement/config inside gearbox.command.Command ? > > Thanks, > Bastien. > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

