Damjan wrote:
I have one sugestion about the MySQL store since that's what I'll be
using (my app already uses MySQL so its normal for me to use it for
sessions too).
You store the pickle of the session object in the MySQL database in a
"text" column... this is not a very good choice because since MySQL-4.1
a text (or varchar) column type has some special semantics. MySQL now
cares about the charset of the column, and it's no longer binary
transparent.
I'd suggest to use "BLOB" type for the `pickle` collumn.
This will require a very small change in MySQLSessionStore.py
(attached for your convenience)..
PS. How I was bitten by this issue...
I found out about this, since in my publisher I reused the MySQLdb
connection that I use in the "model" part of my application.
I connect to the database like this:
db = MySQLdb.connect(dbhost,dbuser,dbpass,dbname,use_unicode=1)
db.charset = 'utf8'
This makes all text (varchar, char) fields returned by MySQLdb as
unicode strings, automatically converted from the 'db.charset' charset
to Unicode.
Of course MySQLSessionStore.py raised an exception when it tried to
use pickle.loads on a unicode object.
That was the problem I had. I'm using MySQL 4.0, and with a BLOB type
it returns unicode, which pickle refuses to accept, even when I str()
it. Do you know how to get pickle to accept it? You mentioned an
attachment but there isn't any.
I've also heard there are certain binary values that can't be
represented in SQL and you have to use an escape function, but I didn't
see any SQL escape function that looked suitable. Maybe MySQLdb handles
that automatically.
If we could use a BLOB we could advance to pickle protocol 3, which
would be better for new-style instances in the session.
_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users