collective.saconnect 1.4

A Plone control panel for SQL Alchemy connection strings

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!

What's new in collective.saconnect 1.4:

  • 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]
Read full changelog
send us
an update
GPL (GNU General Public License) 
Jarn AS
ROOT \ Internet \ Plone Extensions
collective.saconnect is a Plone product that 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 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
 / >
def saconnectionUpdated(connections, event):
 if 'myconnectionstring' in event.descriptions:
 getUtility(IDatabase, u'myconnection').invalidate()

Last updated on October 6th, 2011


#SQLAlchemy connection #control panel #Plone #control #panel #SQLAlchemy

Add your review!