[FIX] fields.binary: allow writing base64 unicode string values
authorOlivier Dony <odo@openerp.com>
Wed, 22 Feb 2012 09:39:37 +0000 (10:39 +0100)
committerOlivier Dony <odo@openerp.com>
Wed, 22 Feb 2012 09:39:37 +0000 (10:39 +0100)
commitb5db852b3acd0934ec3e44e3bdc56aadebb769b2
tree0c4e02851b1fc55ac43a7fb68456d569882e4304
parentc881a2b13473025dc698d51841e769d218913f3b
[FIX] fields.binary: allow writing base64 unicode string values

The fields.binary type allows storing arbitrary
byte arrays, but it has been used historically
to store base64-encoded versions of the binaries.
This was partially related to the way these binary
values are serialized when transferred using the
standard XML-RPC protocol.
With the introduction of JSON-based RPC calls
alongside the 6.1 web client, these base64-encoded
binaries may now be deserialized as unicode ASCII
strings instead of 8-bit strings. That seems like
an acceptable behavior and we can simply coerce
these unicode strings to bytes strings as we know
they will be pure ASCII. Any non-ASCII unicode
value for binary field makes no sense and should
be passed as a byte string directly.

Thanks to Rui Barreiros for providing the final
hint in bug 919982 comments that lead to the
identification of this bug.

lp bug: https://launchpad.net/bugs/899794 fixed

bzr revid: odo@openerp.com-20120222093937-quifmtsfc9gaa9ar
openerp/osv/fields.py