用于sql炼金术连接字符串的plone控制面板
collective.saconnect的Python项目详细描述
简介
这个包为SQLAlchemy连接字符串提供了一个简单的控制面板和存储空间。 它提供了一个可以添加和删除命名连接的表单,以及一个管理这些连接的gs导入和导出步骤。
这个包不提供sqlalchemy集成本身; 改用类似zope.sqlalchemy、collective.lead或pas.plugins.sqlalchemy的库。
示例用法:
from zope.app.component.hooks import getSite from collective.saconnect.interfaces import ISQLAlchemyConnectionStrings saconnect = ISQLAlchemyConnectionStrings(getSite()) myconnection = saconnect['myidentifier']
ISQLAlchemyConnectionStrings充当一个简单的字典,尽管它的键和值必须是简单的字符串。
要通过genericsetup导入连接字符串,只需在配置文件中包含一个名为saconnections.xml的文件,其中每个连接包含一个顶级的“connections”元素和一个“connection”元素,并具有名称和字符串属性:
<?xml version="1.0"?> <connections> <connection name="bar" string="sqlite:////path/to/bar.sqlite"/> <connection name="foo" string="oracle://username:password/tnsnamethere"/> </connections>
要删除任何连接,请使用“remove”属性:
<?xml version="1.0"?> <connections> <connection name="bar" remove=""/> </connections>
如果缓存sqlalchemy连接,则可能需要侦听isqlalchemyconnectionstrings的iobjectmodifiedvent。 事件包括修改字符串的键,因此您可以轻松刷新数据库连接:
<subscriber handler=".mymodule.saconnectionUpdated" for="collective.saconnect.interfaces.ISQLAlchemyConnectionStrings zope.lifecycleevent.interfaces.IObjectModifiedEvent" />
def saconnectionUpdated(connections, event): if 'myconnectionstring' in event.descriptions: getUtility(IDatabase, u'myconnection').invalidate()
贡献
如果你有问题,请告诉我们。
- 问题跟踪程序:https://github.com/collective/collective.saconnect/issues
- 源代码:https://github.com/collective/collective.saconnect
您可以克隆源并提交pull请求或get access to the github-collective,然后直接在项目存储库上工作。
更改日志
2.0.1(2016-04-04)
- 固定包装
2.0(2016-03-31)
- 大修:自动EP8/手动PEP8,UTF8割台,建造/安装现代化 [詹森]
1.4(2011-10-06)
- 在plone 4下包含cmfcore的permissions.zcml,因此cmf.manageportal 许可是已知的。 [汉诺什]
- 修复阻止z3c.saconfig支持启用的输入错误。 [埃尔罗]
1.3(2009-05-28)
- 将z3cform依赖项更新为plone.app.z3cform,并添加include configure.zcml中的配置。 [MJ]
- 添加了对z3c.saconfig连接的可选支持;每个连接 collective.saconnect中的字符串自动注册为z3c.saconfig 作用域会话实用程序。 [美赞臣埃尔罗]
1.2(2009-03-20)
- 修复了在编辑修复后添加新条目的问题。 [MJ]
1.1(2009-03-17)
-
固定编辑现有条目。
[MJ]
1.0(2009-03-17)
- 初次发行 [MJ]