My favorites | Sign in
Project Home Wiki Issues Source
Search
for
AdvancedUsage  
Using custom SQLAlchemy ORM objects
Featured
Updated Oct 8, 2007 by paul.jos...@gmail.com

Custom Objects

Tranquil will look in every installed app for an importable item called 'alchemy'. What this means to you is that if you place a file alchemy.py in your application's folder, it will be checked for customized Table and Mapper classes.

alchemy.py

Basically, all you have to do to make this work is drop in a file with some SQLAlchemy objects created.

Caveats

  • Use a blank MetaData object when creating your objects. They will be imported automatically into the correct MetaData object by Tranquil.
  • Assign the value of mapper(...) to a variable. SQLAlchemy doesn't usually do this, but Tranquil needs to have access to the instances after they are created. This is easier than mucking around in SQLAlchemy's internals and pulling them out of the WeakRef cache.

Check out the ExampleAlchemy page.


Sign in to add a comment
Powered by Google Project Hosting