On May 20, 1:45 am, Mihail Lukin <[email protected]> wrote:
> Hello, community!
>
> I use existing database and reflected SA models in my TG2 application.
> I followed Pylons guide [1] to create custom paster command for my
> application. The problem is that I cannot use this models in this
> command, because they are not initialized before executing it.
>
> What is the best way to do all the initialization before executing
> paster command?
I do something similar (I have a Python script outside my app that
needs to use the objects in my app). I stole the below code from some
auto generated file in my turbogears app (websetup.py?) :
================================================
import os
from paste.deploy import appconfig
from my_tg_site.config.environment import load_environment
from my_tg_site import model
def load_config(filename):
conf = appconfig('config:' + os.path.abspath(filename))
load_environment(conf.global_conf, conf.local_conf)
return conf
conf = load_config("development.ini")
# now I can access stuff in my TG app
==================================
Hope this helps!
_Ryan Wilcox
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.