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.
> 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.
> > 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.
James wrote: > 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.
> James wrote: >> 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.
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:
> If you find it useful, let me know, and I'll stick the reference up > in a more permanent location.
> -- Anthony
> On 28-Jan-10, at 1:38 PM, Mike C. Fletcher wrote:
> > James wrote: > >> 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.