Having the following error AttributeError: 'NoneType' object has no attribute 'sa_engine'
on this line in model/init.py
Session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
bind=config['pylons.g'].sa_engine))
When printing config dictionary, it has 'pylons.g' key but value at this key is None.
I do not understand why it is None, config['pylons.g'] is initialized in environment.py as
config['pylons.g'] = app_globals.Globals()
Any ideas?
By the way, initially there no config['pylons.开发者_Python百科g'] code in the project. It was config['pylons.app_globals'] but when I tried to use it, it was not in dictionary at all.
I would recommend against binding the session at import time. Do it inside init_model() instead:
def init_model(engine): meta.Session.configure(bind=engine)
精彩评论