Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install collective.saconnect

How to install collective.saconnect

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install collective.saconnect
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.4 Available View build log
1.3 Available View build log
Windows (64-bit)
1.4 Available View build log
1.3 Available View build log
Mac OS X (10.5+)
1.4 Available View build log
1.3 Available View build log
Linux (32-bit)
1.4 Available View build log
1.3 Available View build log
Linux (64-bit)
1.4 Available View build log
1.3 Available View build log
 
Author
License
GPL
Lastest release
version 1.4 on Oct 7th, 2011

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 or collective.lead 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()
Credits
Development sponsored by
Elkjøp Nordic AS
Design and development
Martijn Pieters at Jarn

Changelog

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]

Subscribe to package updates

Last updated Oct 7th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.