Announcing Montague: The new way to configure Python applications

Python ships with a library called ConfigParser which loads Windows-style INI files. For a long time, ConfigParser (and layers on top of it such as PasteDeploy) has been a standard way to configure Python applications, despite its shortcomings. Back in December, I began to get very frustrated with the INI format, particularly PasteDeploy's implementation. Using modern deployment tools like Heroku or Docker means pulling configuration data from environment variables, but INI files have limited support for interpolation, and what support they do have is not very transparent. PasteDeploy also unnecessarily combines loading the configuration data from the INI file with…

read more...

Testing SQLAlchemy/Pyramid apps without a Scoped Session

@inklesspen like your post on switching up the session in Pyramid, but how do you deal with needing it in tests, etc?— Security Snarchitect (@petrillic) January 8, 2015 This is an excellent question; if you follow my guidance in the Zope Transaction post and do nothing else, your tests will break and it won't be immediately obvious how to fix them. (Actually, if you follow my guidance in the post and do nothing else, your app won't run, because you'll be left with some files importing a global DBSession that no longer exists. Details.) Anyway, this topic is now…

read more...

What the Zope Transaction Manager Means To Me (and you)

If you use Python and you use SQL databases, you probably use SQLAlchemy. It's an ORM, it's a SQL DSL, it's extremely powerful and flexible. If you use a web app framework, you generally want to tie the lifecycle of your database transactions into the lifecycle of your HTTP request handling. Different web frameworks offer different approaches for this; if you use the Pyramid web framework, you have probably encountered something called the Zope Transaction Manager. There's actually three Python packages at work here; if you use the Pyramid scaffold with SQLAlchemy support, they automatically get integrated into your app.…

read more...

How Expired Root Certificates Broke My Python App Build

A few days ago, Python 2.7.9 was released, with a very unusual feature change for a subminor release. HTTPS certificate validation is now enabled by default in the Python standard libraries. Since I use Homebrew, upgrading was very easy. Of course, replacing the Python interpreter broke all my virtualenvs, but that was quickly fixed. I set about regenerating all the tox environments for my latest project and then something strange happened. Coveralls.io provides coverage information for Python projects. Very handy, very useful public service. Except according to sphinx linkcheck, the website had an expired certificate, which caused…

read more...