开发者

config['pylons.g'] AttributeError pylons

开发者 https://www.devze.com 2022-12-25 11:34 出处:网络
Having the following error AttributeError: \'NoneType\' object has no attribute \'sa_engine\' on this line in model/init.py

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消