On Sep 21, 2013, at 1:27 AM, John Nieri <[email protected]> wrote:

> Hello, I've searched on this topic but haven't found anything approaching 
> authoritative. I'm also new to DBs and SQLAlchemy although not new to python.
> 
> I'd like to know if there is some mechanism in SQLAlchemy for the common case 
> of having translated / localized content for a given column.
> 
> What I would like to do is something like this:
> 
>     title = Column(LocalizedString)  # or title = LocalizedColumn(String)
>     # ...
>     title = obj.title["en-US"]  # or something similar
> 
> I started making my own implementation but I worry that a) it has been done 
> before a thousand times b) whatever I come up with won't work with the 
> underlying magic of SQLAlchemy. I like the approach of atomic translations 
> but I haven't found implementations of it.
> 
> If anyone could point me in the right direction or just tell me that such a 
> thing doesn't exist, I would appreciate it.

if you want data translation (of any kind) to occur at the column level, this 
is very common and is achieved using the TypeDecorator mechanism:

http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#augmenting-existing-types

a series of recipes follow that section as well (though not yet one for i8ln)

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to