SQLAlchemy连接字符串的Plone控制面板
项目描述
简介
此包提供了一个简单的控制面板和存储,用于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 的 IObjectModifiedEvent。该事件包括修改字符串的键,这样你就可以轻松地刷新你的数据库连接。
<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()
贡献
如果你遇到问题,请告诉我们。
你可以克隆源代码并提交拉取请求,或者 获得对 github-collective 的访问权限 并直接在项目仓库中工作。
变更日志
2.0.1 (2016-04-04)
修复了打包问题
2.0 (2016-03-31)
重整:autopep8/manual pep8,utf8-header,buildout/setup 现代化 [jensens]
1.4 (2011-10-06)
在 Plone 4 中包含 CMFCore 的 permissions.zcml,以便 cmf.ManagePortal 权限被识别。[hannosch]
修复了阻止 z3c.saconfig 支持始终启用的错误。[elro]
1.3 (2009-05-28)
更新 z3cform 依赖到 plone.app.z3cform,并在 configure.zcml 中添加其配置。[mj]
添加了对 z3c.saconfig 连接的可选支持;collective.saconnect 中的每个连接字符串都会自动注册为 z3c.saconfig 作用域的会话实用程序。[elro, mj]
1.2 (2009-03-20)
修复了编辑修复后的添加新条目。[mj]
1.1 (2009-03-17)
修复了编辑现有条目。[mj]
1.0 (2009-03-17)
初始发布 [mj]
项目详情
集体.saconnect-2.0.1.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cf3a33644fd5fccd62b029a4b1995100f302728d0f0cf67350638e953c5f471b |
|
MD5 | a49f3d3e674ac7cf5110072161339332 |
|
BLAKE2b-256 | 377a343a2f0ce8847eab53265adc736b2c6c07d6055fdef50d4cf3bace6c184f |