Skip to main content

Plone Control Panel for SQL Alchemy connection strings

Project description

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

Introduction

This package provides a simple control panel and storage for SQLAlchemy connection strings. It presents a form where one can add and remove named connections, and a GS import and export step to manage these.

This package does not provide SQLAlchemy integration itself; use a library like zope.sqlalchemy, collective.lead or pas.plugins.sqlalchemy instead.

Example usage:

from zope.app.component.hooks import getSite
from collective.saconnect.interfaces import ISQLAlchemyConnectionStrings

saconnect = ISQLAlchemyConnectionStrings(getSite())
myconnection = saconnect['myidentifier']

ISQLAlchemyConnectionStrings acts as a simple dictionary, although it’s keys and values must be simple strings.

To import connection strings through GenericSetup, simply include a file named saconnections.xml in your profile, with a top-level ‘connections’ element and one ‘connection’ element per connection, with name and string attributes:

<?xml version="1.0"?>
<connections>
 <connection name="bar" string="sqlite:////path/to/bar.sqlite"/>
 <connection name="foo" string="oracle://username:password/tnsnamethere"/>
</connections>

To remove any of the connections, use the ‘remove’ attribute:

<?xml version="1.0"?>
<connections>
  <connection name="bar" remove=""/>
</connections>

If you cache your SQLAlchemy connections, you may want to listen for the IObjectModifiedEvent for ISQLAlchemyConnectionStrings. The event includes the key of the modified string, so you can easily refresh your database connections:

<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()

Contribute

If you are having issues, please let us know.

You can clone the source and submit pull requests or get access to the github-collective and work directly on the project repository.

Changelog

2.0.1 (2016-04-04)

  • fixed packaging

2.0 (2016-03-31)

  • Overhaul: autopep8/manual pep8, utf8-header, buildout/setup modernized [jensens]

1.4 (2011-10-06)

  • Include CMFCore’s permissions.zcml under Plone 4, so the cmf.ManagePortal permission is known. [hannosch]

  • Fix typo that prevented z3c.saconfig support from ever being enabled. [elro]

1.3 (2009-05-28)

  • Update z3cform dependency to plone.app.z3cform, and add include it’s configuration in configure.zcml. [mj]

  • Added optional support for z3c.saconfig connections; each connection string in collective.saconnect automatically is registered as a z3c.saconfig scoped session utility. [elro, mj]

1.2 (2009-03-20)

  • Fixed adding new entries after the editing fix. [mj]

1.1 (2009-03-17)

  • Fixed editing existing entries. [mj]

1.0 (2009-03-17)

  • Initial release [mj]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.saconnect-2.0.1.tar.gz (11.0 kB view details)

Uploaded Source

File details

Details for the file collective.saconnect-2.0.1.tar.gz.

File metadata

File hashes

Hashes for collective.saconnect-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cf3a33644fd5fccd62b029a4b1995100f302728d0f0cf67350638e953c5f471b
MD5 a49f3d3e674ac7cf5110072161339332
BLAKE2b-256 377a343a2f0ce8847eab53265adc736b2c6c07d6055fdef50d4cf3bace6c184f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page