Re: session2: a persistent session library

Damjan <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
> That was the problem I had.  I'm using MySQL 4.0, and with a BLOB type 
> it returns unicode, 

Thats strange, it shouldn't return a unicode object??! It returns an
array.array object for me.
Btw, Im using MySQLdb 1.2.0 and MySQL 4.1.11

> 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.

Argh. I hate it when this happens, here it goes...

> 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.

Probably MySQLdb does 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.

Can you send me a patch to enable that, so that I can test it?


-- 
damjan | дамјан
This is my jabber ID --> [email protected] <-- not my mail address!!!

_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users
MySQLSessionStore.diff (text/plain, 639 B)
--- MySQLSessionStore.py.old	2005-06-19 03:59:46.000000000 +0200
+++ MySQLSessionStore.py	2005-06-18 04:19:12.000000000 +0200
@@ -42,7 +42,7 @@
         if c.rowcount == 0:
             return default
         assert c.rowcount == 1, "more than one session with id %s" % (id,)
-        pck = c.fetchone()[0]
+        pck = c.fetchone()[0].tostring()
         obj = pickle.loads(pck)
         return obj
 
@@ -74,7 +74,7 @@
         c.execute("""\
 CREATE TABLE %s (
 id VARCHAR(255) NOT NULL PRIMARY KEY,
-pickle TEXT NOT NULL,
+pickle BLOB NOT NULL,
 modify_time TIMESTAMP)""" % self.table)
 
     def delete_old_sessions(self, minutes):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.