Hi,
Perfect. I used it with success.
Thank you !
On 01/28/2016 04:57 PM, Alessandro Molina wrote:
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] <mailto:[email protected]>> wrote:
Hi,
I can't access to app configuration inside my command:
|
# -*- coding: utf-8 -*-
fromgearbox.command importCommand
fromtg importconfig
classCrawlCommand(Command):
deftake_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
>>>fromtg importconfig
>>>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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[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 a topic in the
Google Groups "TurboGears" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/turbogears/sQc_YvfOocU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[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.