Skip to main content

Configure a Data source name for Zope

Project description

https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336:target:https://pycqa.github.io/isort/

visaplan.zope.reldb

This package simply provides the configuration of a Data source name (DSN), e.g. for use with SQLAlchemy.

For the heavy lifting of integration of database transactions of your relational database (like PostgreSQL or whatever) with the ZODB, you’ll likely want to use something like zope.sqlalchemy, which in turn requires sqlalchemy to talk to the database. However, zope.sqlalchemy doesn’t offer a configuration method for the DSN. This packages offers to store this DSN in the Zope configuration file (parts/clientN/etc/zope.conf).

The idea is: You might have several instances of your Zope (for production, testing, development …), and every now and then you replicate the productive data. With the DSN stored in the ZODB, you’d have this information replicated as well, which might not work for you; you might have different databases on the same database server, or the production server connects to the database by socket which is not possible in your development instance, or whatever.

Features

  • Stores a DSN string in the Zope configuration and provides a get_dsn function.

  • With SQLAlchemy installed,

    • creates an Engine and a DBSession, and

    • provides an optional .legacy.SQLWrapper context manager class which sports a few simple insert, update, delete, select and query methods

  • With zope.sqlalchemy installed as well, registers that DBSession for the transaction machinery integration.

Installation

Add the package to your product requirements somehow; since we’ll need to add a product configuration as well, you’ll most likely add it to your eggs value in your buildout script (buildout.cfg):

[buildout]

...

eggs =
    your.fancy.product
    visaplan.zope.reldb

Add a product configuration there as well, containing your data source name:

[buildout]

...

[instance_base]
...
zope-conf-additional =
    <product-config reldb>
    dsn postgresql+psycopg2://localhost/mydb
    </product-config>

(We follow the convention used by the UnifiedInstaller here; your section(s) might be named differently.)

After running bin/buildout and restarting your Zope instance, the product configuration should have been added to your zope.conf file(s), and your.fancy.product can read the DSN string by calling visaplan.zope.reldb.get_dsn (or, if you have SQLAlchemy, directly use visaplan.zope.reldb.engine.engine).

Remark

“But, can’t my product simply do all this by itself?!”

Sure. Having this as a package helps / helped us to switch a whole bunch of packages from usage of Zope database adapters (stored in the ZODB) to sqlalchemy (with a DSN configured in the zope.conf file(s)).

Contribute

Support

If you are having issues, please let us know; please use the issue tracker mentioned above.

License

The project is licensed under the GPLv2.

Futher reading

Contributors

Changelog

1.0.0 (unreleased)

  • Initial release. [tobiasherp]

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

visaplan.zope.reldb-1.0.0.dev2.tar.gz (27.9 kB view details)

Uploaded Source

File details

Details for the file visaplan.zope.reldb-1.0.0.dev2.tar.gz.

File metadata

  • Download URL: visaplan.zope.reldb-1.0.0.dev2.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.5

File hashes

Hashes for visaplan.zope.reldb-1.0.0.dev2.tar.gz
Algorithm Hash digest
SHA256 9449754953bafb7a1fd6bf99922c7ac2e7d865f4c5abe5af1cc5660cbf06733c
MD5 3132f7abd2e7fc36683757af43c2e5b4
BLAKE2b-256 29e0a2a9eb09075973d324501e32c44a34821b79e18e03a919fb38be64f34cbc

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