跳转到主要内容

SQLAlchemy连接字符串的Plone控制面板

项目描述

https://travis-ci.org/collective/collective.saconnect.svg?branch=master https://coveralls.io/repos/collective/collective.saconnect/badge.svg?branch=master&service=github

简介

此包提供了一个简单的控制面板和存储,用于SQLAlchemy连接字符串。它提供了一个表单,可以添加和删除命名连接,并提供GS导入和导出步骤来管理这些连接。

此包本身不提供SQLAlchemy集成;请使用如zope.sqlalchemycollective.leadpas.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]

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面