棱锥体SQLAlchemy扩展
pyramid_sqlalchemy_utilit的Python项目详细描述
注册sqlalchemy实用程序的简单金字塔扩展。它增加了 sqla_session请求对象的属性。会话在第一次访问时打开 并在请求完成回调时自动提交和关闭。
它收紧sqlalchemy会话以请求生命周期,而不是依赖线程 sqlalchemy文档中建议的本地作用域会话:
The Session can be established as the request begins, or using a lazy initialization pattern which establishes one as soon as it is needed. The request then proceeds, with some system in place where application logic can access the current Session in a manner associated with how the actual request object is accessed. As the request ends, the Session is torn down as well, usually through the usage of event hooks provided by the web framework.
源代码和示例可在https://github.com/hadrien/pyramid_sqlalchemy_utility