核心GS配置
gs.config的Python项目详细描述
Authors: | Richard Waid
Michael JasonSmith |
---|---|
Contact: | Michael JasonSmith <mpj17@onlinegroups.net> |
Date: | 2015-03-17 |
Organization: | GroupServer.org |
Copyright: | This document is licensed under a Creative Commons Attribution-Share Alike 4.0 International License by OnlineGroups.net. |
简介
有时配置很复杂,例如 需要配置,因为一个系统的多个实例 (例如groupserver[1])正在同一个安装程序上运行。在 这种情况下,每个实例都由一组组件组成,并且 每个组件都由配置选项组成:
- 实例
- 成分
- 配置选项
- 更多配置选项
- 成分2
- 不同的配置选项
- 成分
- 另一个实例
遗憾的是ConfigParser系统不允许这种层次结构, 但是gs.config可以,通过使用namespace来提供 实例和组件之间的关系。在 特别是,这个产品提供一个Config class来读取 ^特定结构的{a4}。
Config类
表示系统的gs.config.Config类 配置。请参阅本模块中的sphinx文档以了解 更多信息。
文件
实例用名称[config-${name}]标记,其中 ${name}是实例的名称。例如[config-production] 对于实例production。
然后为每个部件提供一组部件:
[config-production] database = production smtp = external cache = production tokenauth = production
组件的配置可以由多个 实例:
[config-staging] database = production smtp = dead cache = none tokenauth = production
每个组件都是一个配置节,具有表单的名称 [${component}-${name}]。例如[smtp-external]对于 名为external的SMTP节。
示例
在下面的示例中,配置了三个实例:一个用于 测试服务器,一个用于登台服务器,一个用于生产 服务器。每个实例都有两个组件:数据库和smtp 服务器:
[config-test] database = test smtp = test [config-staging] database = live smtp = test [config-production] database = live smtp = live # An actual configuration section for each configuration set [database-test] dsn = postgres://name:pass@server/database-test [database-live] dsn = postgres://name:pass@server/database-live [smtp-test] server = localhost port = 2525 [smtp-live] server = external port = 25
当配置被实例化时,会传递一个id。此ID标识 当前正在访问的配置集。如果身份证不是 通过,尝试从环境中获取ID 自动。目前这是特定于GroupServer 环境,尽管要小心确保它会倒退 优雅地被传递一个ID。
资源
- 文档:http://groupserver.readthedocs.org/projects/gsconfig
- 代码库:https://github.com/groupserver/gs.config
- 问题和评论 http://groupserver.org/groups/development
- 在https://redmine.iopen.net/projects/groupserver 报告错误
[1] | While originally written for GroupServer, there is no code in this product that is specific to GroupServer. However, this product is used to configure the database, SMTP, cache, and token authentication for GroupServer. |