durusmail: quixote-users: session2: a persistent session library
session2: a persistent session library
2005-06-13
2005-06-18
2005-06-18
2005-06-19
2005-06-19
session2: a persistent session library
Damjan
2005-06-18
> Titus and I have put together a persistent session library for Quxiote.
> Give it a try at http://quixote.idyll.org/session2/ and let us know of any
> bugs or feedback.  It comes with five stores: file-based (with fcntl
> locking), Durus, MySQL, PostgreSQL (psycopg), and Shelve.

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.


--
damjan | дамјан
This is my jabber ID --> damjan@bagra.net.mk <-- not my mail address!!!
reply