一个用于plaster的PasteDeploy语法的加载器。
项目描述
plaster_pastedeploy 是一个 plaster 插件,它提供了一个 plaster.Loader,可以根据 PasteDeploy 的标准解析 ini 文件。它支持 wsgi plaster 协议,实现了 plaster.protocols.IWSGIProtocol 接口。
用法
应用程序应使用 plaster_pastedeploy 从配置源(通常是文件)的命名部分中加载设置。
有关如何将此加载器集成到应用程序中的信息,请参阅 plaster 的文档。
请查看PasteDeploy的文档,了解支持的INI文件格式详情。
大多数应用程序将想要使用plaster.get_loader(uri, protocols=['wsgi'])来获取此加载器。然后它暴露了get_wsgi_app、get_wsgi_app_settings、get_wsgi_filter和get_wsgi_server。
import plaster
loader = plaster.get_loader('development.ini', protocols=['wsgi'])
# to get any section out of the config file
settings = loader.get_settings('app:main')
# to get settings for a WSGI app
app_config = loader.get_wsgi_app_settings() # defaults to main
# to get an actual WSGI app
app = loader.get_wsgi_app() # defaults to main
# to get a filter and compose it with an app
filter = loader.get_wsgi_filter('filt')
app = filter(app)
# to get a WSGI server
server = loader.get_wsgi_server() # defaults to main
# to start the WSGI server
server(app)
任何plaster.PlasterURL选项都将作为默认值转发到加载器。以下是一些示例
development.ini#myapp
development.ini?http_port=8080#main
pastedeploy+ini:///path/to/development.ini
pastedeploy+ini://development.ini#foo
egg:MyApp?debug=false#foo
1.0.1 (2022-11-06)
小版本发布以清理README。
1.0 (2022-11-06)
停止支持Python 2.7、3.4、3.5、3.6。
添加对Python 3.8、3.9、3.10的支持。
黑化代码库。
将CI切换到Github Actions。
0.7 (2019-04-12)
支持Python 3.7。
依赖pastedeploy >= 2.0以在覆盖默认值时强制执行新行为。传递给加载器的默认值将覆盖[DEFAULT]部分的值。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/17
0.6 (2018-07-11)
将setup_logging更改为使用带有disable_existing_loggers=False的logging.config.fileConfig调用,以避免禁用在配置日志系统之前导入的任何记录器。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/16
0.5 (2018-03-29)
现在完全移除了环境变量支持。该功能需要在PasteDeploy中上游进行错误修复,这些修复尚未完成,因此它现在已被删除。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/15
0.4.2 (2017-11-20)
修复ConfigDict.copy以便它正常工作。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/14
0.4.1 (2017-07-10)
在Python 2上禁用环境变量支持。由于PasteDeploy不支持在Python 2上转义内容,因此任何具有如下格式的值%(foo)s都会破坏解析器。因为这是隐式行为,所以被认为支持太多错误,因此不支持。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/10
转义环境变量,以便其内容不受插值的约束。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/10
当调用setup_logging且配置文件不包含任何日志设置或URI使用egg:协议时,调用logging.basicConfig。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/11
0.4 (2017-07-09)
修复get_settings以任意部分为任意部分提供支持,以遵循PasteDeploy在处理默认值方面的规则。该包的目标是与PasteDeploy的格式兼容,以便在文件的所有部分中都不会有令人惊讶的格式更改。
支持添加了set default_foo = bar和get foo = default_foo语法来覆盖默认值以及分别将默认值拉入设置。在上面的示例中,将返回值foo = bar。通过插值或get语法未拉入该部分的任何其他默认值都将被忽略。
自动将环境变量注入到默认值中。这些将作为ENV_<foo>可用以插值。例如,如果环境变量APP_DEBUG=true,则%(ENV_APP_DEBUG)s在ini文件中将工作。请参阅https://github.com/Pylons/plaster_pastedeploy/pull/7
get_settings 和 get_wsgi_app_settings 现在都只返回本地配置。然而,返回的对象具有包含默认值的 global_conf 属性以及指向加载器实例的 loader 属性。请参阅 https://github.com/Pylons/plaster_pastedeploy/pull/8
0.3.2 (2017-07-01)
解决了一个问题:如果从 PyPI 安装了 configparser 模块,Python 2.7 中的 NoSectionError 不会正确捕获。请参阅 https://github.com/Pylons/plaster_pastedeploy/issues/5
0.3.1 (2017-06-02)
识别 pastedeploy+egg 方案为 egg 类型。
0.3 (2017-06-02)
删除 ini 方案,并用 file+ini 和 pastedeploy 替换。同时,将 ini+pastedeploy 和 egg+pastedeploy 分别重命名为 pastedeploy+ini 和 pastedeploy+egg。请参阅 https://github.com/Pylons/plaster_pastedeploy/pull/4
0.2.1 (2017-03-29)
修复了 0.2 版本中的一个错误,该错误在使用非基于配置文件的协议时会对无效部分引发异常。
0.2 (2017-03-29)
不再引发 plaster.NoSectionError 异常。对于缺失的部分返回空字典,用户应检查 get_sections 以获取有效部分的列表。
0.1 (2017-03-27)
初始发布。
项目详情
下载文件
下载适合您平台的文件。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。
源分布
构建分布
plaster_pastedeploy-1.0.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | be262e6d2e41a7264875daa2fe2850cbb0615728bcdc92828fdc72736e381412 |
|
MD5 | 79a05aadf9704ffae75e374715aaba4c |
|
BLAKE2b-256 | c7af01a22f73ce97c6375c88d7ceaf6f5f4f345e940da93c94f98833d898a449 |
plaster_pastedeploy-1.0.1-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ad3550cc744648969ed3b810f33c9344f515ee8d8a8cec18e8f2c4a643c2181f |
|
MD5 | 29c33baa01599cee7a7574505a2647f4 |
|
BLAKE2b-256 | bd302d4cf89035c22a89bf0e34dbc50fdc07c42c9bdc90fd972d495257ad2b6e |