[Tutor] Unpickleable object error
Sheila King
sheila@thinkspot.net
Thu, 06 Sep 2001 12:25:21 -0700
OK, so I'm happy as a clam, shelving away my objects into a database
hash file.
I have this type of object:
class user:
def __init__(self, id, passwd, email, mssgList, lastmssg, caller = None):
self.lockfile = MutexFile.MutexFile('userdb.lck')
self.myfilename = 'users'
self.id = id
self.passwd = passwd
self.email = email
self.mssgList = mssgList
self.lasmssg = lastmssg
And another class, called mssgBoard, has this method:
def addUser(self, user):
user.lockfile.flock('LOCK_EX')
userdb = shelve.open(user.myfilename, 'c')
if not userdb.has_key(user.id):
userdb[user.id] = user
userdb.close()
user.lockfile.flock('LOCK_UN')
And I'm running my script, and debugging it, and (it's a cgi script) I get
the typical 500 Internal Server error, and when I check my log files, this
is the error message:
Premature end of script headers: e:/apache/cgi-bin/pibby/init.py
Traceback (most recent call last):
File "e:\apache\cgi-bin\pibby\init.py", line 20, in ?
mainBoard.addUser(admin)
File "e:\apache\cgi-bin\pibby\pbbclass.py", line 34, in addUser
userdb[user.id] = user
File "E:\PYTHON\PYTHON21\lib\shelve.py", line 76, in __setitem__
p.dump(value)
cPickle.UnpickleableError: Cannot pickle <type 'PyHANDLE'> objects
So, I'm thinking either I can't pickle/shelve this data class, as I have defined
it, or else I really don't know what the problem is.
Does anyone have any suggestions on how to proceed?
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/