Including this function in my model/__init__.py does the trick.
import paste.deploy, os.path
def externally_usable_session(configfile = 'development.ini'):
tg_home_directory = '/path/to/tg2instancehomedirectory'
conf_dict = paste.deploy.appconfig('config:%s' % os.path.join(tg_home_directory, configfile))
engine = create_engine(conf_dict['sqlalchemy.url'])
init_model(engine)
return DBSession()
1 comment:
You also have to import sqlalchemy:
from sqlalchemy import *.
Then in your script, you can get the session using:
dbSession = pmodel.externally_usable_session('development.ini')
Post a Comment