Technology and more.

Single Entry

When writing applications using Pyramid web framework a simple option to persist data is using the ZODB. It is sort of built in and very easy to ease. Although being a very stable, reliable and fast database, ZODB does not handle binary data very well. But there is a solution for this: Storing binary data (blobs) transparently outside of the database.

ZODB in newer versions has blob support built in but you need to activate it and handle it the rigth way. Here I want to share my findings and some code to make you successfully use blobs in your Pyramid application. Some parts of the code are inspired by z3c.blobfile.

This code enables you to save binary objects to ZODB. Upon commit the binary data is transparently saved to the file system. This is done by using code like this (assuming that the module containing the code above is called blobfile.py):