Configuration 配置[';挂架.g';]属性错误挂架
具有以下错误AttributeError:“非类型”对象没有属性“sa_engine” 在Configuration 配置[';挂架.g';]属性错误挂架,configuration,pylons,Configuration,Pylons,具有以下错误AttributeError:“非类型”对象没有属性“sa_engine” 在model/init.py Session = scoped_session(sessionmaker(autoflush=True, autocommit=False, bind=config['pylons.g'].sa_engine)) 打印配置字典时,它有'pylons.g'键,但该键的值为None 我不明白为什么它是None,config['pylons.g']在environment.py
model/init.py
Session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
bind=config['pylons.g'].sa_engine))
打印配置字典时,它有'pylons.g'键,但该键的值为None
我不明白为什么它是None,config['pylons.g']在environment.py中初始化为
config['pylons.g']=app\u globals.globals()
有什么想法吗
顺便说一下,项目中最初没有配置['pylons.g']代码。它是config['pylons.app\u globals'],但当我尝试使用它时,它根本不在字典中。我建议不要在导入时绑定会话。改为在init_model()中执行此操作: def初始_型号(发动机): meta.Session.configure(绑定=引擎)
哪个版本的挂架?版本0.9.7,实际上解决了这个问题。忘记在environment.py中初始化它 def init_model(engine): meta.Session.configure(bind=engine)