On Tuesday 27 November 2007, Oleg Broytmann wrote:
> On Tue, Nov 27, 2007 at 03:17:23PM +0100, Markus Gritsch wrote:
> > Having this try/except
> > here unconditionally for all cases
>
>    Let's satisfy all (to possible extent) - let's make a parameter for
> MySQLConnection (and SQLObject DB URI) that allows/prevents the
> try/except. By default it could be "do not protect" (no try/except).

Do not go there. Having an option if there should be a try/except in the 
code sounds like a bad and weird design to me. You you want to catch the 
exception you do not need an option. You can catch the exception at a 
higher lever and deal with it, not hide it in a catch-all-do-nothing 
try/except block. I agree with Markus here, that try/except is asking for 
trouble and having an option is not the solution to it. If someone want 
to have full control over that he should send the blob in unicode already 
so that no conversion takes place. Also having a unicode conversion for a 
blob is wrong. A blob is not a string with a certain encoding that can be 
converted to unicode, is a string of random bytes. One way to make sure 
that you take a blob and store it unmodified is to use the latin1 codec. 
Latin1 maps every byte in the 0..255 range to self. Which is what we want 
to do anyway, because if a send a binary blob to the db, I want it stored 
as it is, I do not want to end up with some other weirdo bytes in the db 
that resulted from an encoding my blob has no relation with.

So I think we should:
1. get rid of the try/except
2. only use the connection encoding to encode strings / string values
3. use latin1 to encode/decode blobs that ensures that they are sent 
unmodified to the db

-- 
Dan

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to