On Wed, May 29, 2013 at 09:16:58PM -0700, alonn wrote:
> Craig this is exactly what I was looking for, would I be right to assume
> that the tg2 functionality is in cmdline.py in class RnmsCommand in the
> _get_config method?:
>
> conf = appconfig('config:' + os.path.abspath(self.args.conf_file))
> load_environment(conf.global_conf, conf.local_conf)
Yes, those two lines are the magic "make tg work" lines. My test
scripts, which don't appear in git, have these lines only.
Actually the first looks like
conf = appconfig('config:' + os.path.absepath('develop.ini'))
One trick I forgot to mention is that you run python setup.py to
setup the stub files in your virtualenv bin directory.
So for something I will want to use all the time and have the end-user
have available, I use the proper Paster scripts as you can see in git.
For the quick and dirty "wonder if this works" scripts that noone will
ever see I have:
import os
from paste.deploy import appconfig
from myapp.config.environment import load_environment
conf = appconfig('config:' +os.path.abspath('development.ini'))
load_environment(conf.global_conf, conf.local_conf)
This gives you the absolute minimum to get something going with the database
enabled and the usual tg parameters set. Don't use it for stuff anyone will
see, you will regret it in the future (or they will, or both).
> BTW I guess class foo is just some example code lying there?
Old code, it was how I was going to do it.
While looking at my RnmsCommand I noticed I've switched parsers. The
one shown in some of the Paste examples uses the old crummy optparse
which is deprecated while I have used the argparse one; use argparse
its better (and for one of my scripts was essential - I think it was
rnms_info)
Obviously you will probably want a different set of default options.
My logging options may look a bit wierd, but it is sort of how most
daemons work.
- Craig
--
Craig Small VK2XLZ http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5
--
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 http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.