On Oct 11, 2007, at 5:25 AM, Werner F. Bruhin wrote:

>
> Could you give me some hints on how I could do the following in SA.
>
> - define a column as I18N (actual value is a varchar)
> - when the column is read take the value from the table column, do a
> lookup with it in the i18n translation table with a stored  
> procedure and
> either return what was found or the original value
> - the column should ideally be read only
> - to be able to maintain the column I was thinking of setting up a
> second model for the same table where the i18n column would be defined
> as varchar to allow to set the value to be translated
>
> I would really appreciate if you could push me in the right  
> direction on
> this.
>

i'd embed the SP call explicitly in the select():

select([table.c.id, table.c.foo, table.c.bar, func.convert_I18n 
(table.c.data).label('data')]).where(...)

if using the ORM, set up the column explicitly:

mapper(SomeClass, sometable, properties={
        'data':column_property(func.convert_I18n(table.c.data).label('data'))
})

this way you dont add any statement overhead to the type conversion  
(embedding in the TypeEngine means, number of I18N columns * total  
number of rows number of SQL executions).

If I were doing this I also might use TypeEngine for the conversion  
but I'd move the I18N function into Python.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to