Models outside TG2

15 views
Skip to first unread message

James

unread,
Jan 28, 2010, 12:34:30 PM1/28/10
to TurboGears
Hello all,
What's the easiest way to recreate the environment created by "paster
shell"?

I need to run a few non-trivial scripts which use the TG configuration
and model; having to do "paster shell <myscript.py" would be really
awkward as I want to pass in command line arguments to my script.

It seems the pieces I need are the locating and reading-in of a
configuration file and the creation of a SQLAlchemy engine I can pass
to model.init_model.

Any suggestions?
James

Daniel Fetchinson

unread,
Jan 28, 2010, 2:31:07 PM1/28/10
to turbo...@googlegroups.com

http://www.google.com/search?q=models+outside+tg2

And you are feeling lucky :)

HTH,
Daniel

--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

James

unread,
Jan 28, 2010, 4:32:51 PM1/28/10
to TurboGears
Ah, sorry - should have mentioned that I found that page.

It does, indeed, seem to be exactly what I need. Unfortunately,
http://turbogears.org/2.0/docs/_static/wiki20/_download/tg_shell_setup.py,
which purports to hold the magic, is an empty file...

Does tg_shell_setup.py exist anywhere else?

Thanks!
James

On Jan 28, 8:31 pm, Daniel Fetchinson <fetchin...@googlemail.com>
wrote:

Mike C. Fletcher

unread,
Jan 28, 2010, 4:38:02 PM1/28/10
to turbo...@googlegroups.com
http://blog.vrplumber.com/index.php?/archives/2384-TurboGears-offline-processes-crons,-command-line-commands,-etc.html

The tgcommand.py module should show up in TG 2.1, its waiting on my
getting documentation written up in RST format.

HTH,
Mike

--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Anthony Theocharis

unread,
Jan 28, 2010, 5:40:52 PM1/28/10
to turbo...@googlegroups.com
If I understand your question, James, you might want something like
I've been using:

http://pastebin.ca/1769952

If you find it useful, let me know, and I'll stick the reference up
in a more permanent location.

-- Anthony

James

unread,
Jan 29, 2010, 4:10:35 AM1/29/10
to TurboGears
Great! Thanks Anthony, this is just what I was looking for.

I added one more thing to get the logging set up as specified in the
configuration file:
from paste.script import command
cmd = command.Command('dummy')
cmd.logging_file_config(my_ini_file)

Pretty hacky, but it works... Any improvements gladly accepted.

James

On Jan 28, 11:40 pm, Anthony Theocharis <anthony.theocha...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages