10 de janeiro de 2009

Django & Storm

Eita que a coisa está melhorando. A API de integração de Storm com Django foi incluída no pacote do último release de Storm 0.14 que saiu ontem. De acordo com Henstridge:

(...) So it is desirable to have the two ORMs sharing a single connection. The way I’ve implemented this is as a Django database engine backend that uses the connection for a particular named per-thread store and passes transaction commit or rollback requests through to the global transaction manager. Configuration is as simple as:
DATABASE_ENGINE = 'storm.django.backend'
DATABASE_NAME = 'store-name'
STORM_STORES = {'store-name': 'database-uri'}

This will work for PostgreSQL or MySQL connections: Django requires some additional set up for SQLite connections that Storm doesn’t do.

Once this is configured, things mostly just work. As Django and Storm both maintain caches of data retrieved from the database though, accessing the same table with both ORMs could give unpredictable results. My code doesn’t attempt to solve this problem so it is probably best to access tables with only one ORM or the other.

2 comentários:

lins disse...

e um programinha simples de questões jurídicas pra baixar no celular pra matar o tempo, vc não tem?

Eduardo Willians Bandeira de Melo disse...

Infelizmente não tenho nada relacionado a direito, muito menos relacionado a celular :)

Na paz.