allen.fowler wrote:
>
>
>
> On Jun 12, 6:00 am, Gunnlaugur Briem <gunnlau...@gmail.com> wrote:
>> The engine's conversion to unicode doesn't happen when you assign the
>> property, it happens when the underlying database operation is
>> committed, and arrives in the python object's property only after
>> roundtripping through the database.
>>
>
> OK, i see.
>
> Are there any shortcuts for installing a "filter" on the object to
> mandate (and force if possible) UTF-8 on all incoming property
> assignments?

I use this

class _coerce_from_utf8(TypeDecorator):
    def process_bind_param(self, value, dialect):
        if isinstance(value, str):
            value = value.decode('utf-8')
        return value

class UTF8(_coerce_from_utf8):
    """A Unicode type which coerces from utf-8."""

    impl = sa.Unicode

class UTF8Text(_coerce_from_utf8):
    """A Unicode type which coerces from utf-8."""

    impl = sa.UnicodeText




--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to