Jeremy, the added detail you have provided caused me to go back and look at my code to see if I am doing what you are suggesting. It is not obvious to me. I believe I add two things to request.session. One is an update_date that comes from a postgresql database and the other is a status text string. Because the editing session can cross more than one web page, I wanted to remember the update_date to ensure nobody updates my record before I get to update it. I have even gone and looked at the session database records, on one occasion, but did not see anything suspicious. What throws me off, is the pickling error seems to be complaining about the Session cookie name which is a datetime that django takes care of - not me.
The code from django.contrib.sessions.middleware.py in the def SessionMiddleware(object) function fails on line 89: response.set_cookie(settings.SESSION_COOKIE_NAME, session_key, max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN) This is just before it returns response. The line before that creates a new session: new_session = Session.objects.save(session_key, request.session._session, datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)) In my code, view.py functions get called every time a webpage is refreshed or a form gets submitted. I get my problem without submitting any forms, just scrolling thru records viewing them, but this calles the view.py function everytime. As you scroll, the update_date gets changed to the one for the next record, from the database. As I am scrolling, eventually I get this pickling error. I thought I was using straightforward django technique, except for using sqlalchemy to access my database tables. I am going to look at this further, looking for the scenario you have outlined. However, I still don't understand why the code would work fine under certain conditions - ie. mpm-worker or in the django development mode. Mae, you have added a dimension to this for me. Because, I started experiencing this problem when I set up a new PC and used the svn to build the software configuration in site-packages and then added symbolic links from my svn folder. When I discovered that my original machine was using the apache2 mpm-worker and my new target machine was using apache2-prefork, and making it the same fixed the problem, I thought the problem was somehow related to apache2. However, I do not exclude the .pyc files from my svn repository. Maybe I should. I do notice that sometimes you have to reload apache2 to get your latest changes. Maybe this is a characteristic of the prefork apache2 as it only runs one thread (just guessing). I appreciate the time you guys are taking to help me with this. On Apr 5, 12:54 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 4/5/07, Mae <[EMAIL PROTECTED]> wrote: > > > > > Wow, what luck! I've been having a sporadic "" problem, and I've just > > resigned myself to spending today to try to debug it. Searched the > > group for exact error, found nothing, refreshed, and saw this post in > > top slot! Kismet. > > (The error is "TypeError: can't pickle function objects", per a later > email. This error is issued by cPickle rather than pickle, but the > approach is basically the same.) > > In either case, the basic problem is that pickle has to be able to > re-create the objects later, and can only do that if it knows how to > refer to the type of the thing it must create. Pickle refuses to > serialize an object it can't be fairly sure of later de-serializing. > > http://docs.python.org/lib/pickle-inst.html > > Here's a quick example producing this error: > > >>> import cPickle > >>> def z(): > > ...: return 1 > ...: > > >>> class C(object): > > ...: pass > ...: > > >>> c=C() > >>> cPickle.dumps(c) #works fine > > 'ccopy_reg\n_reconstructor\np1\n(c__main__\nC\np2\nc__builtin__\nobject\np3\nNtRp4\n.' > > >>> c.x = z > >>> cPickle.dumps(c) #works fine > > "ccopy_reg\n_reconstructor\np1\n(c__main__\nC\np2\nc__builtin__\nobject\np3\nNtRp4\n(dp5\nS'x'\nc__main__\nz\np6\nsb." > > >>> def z(): #redefine z, which c.x refers to. > > ...: return 2 > ...: > > >>> cPickle.dumps(c) #explodes because the function referred to by c.x > > no longer has a name. > ... > TypeError: can't pickle function objects > > -------------------- > > Similarly, paceman's error is something like this (starting with a new > interpreter!): > > >>> import cPickle > >>> class C(object): > > ...: pass > ...: > > >>> c=C() > >>> cPickle.dumps(c) #works fine > > 'ccopy_reg\n_reconstructor\np1\n(c__main__\nC\np2\nc__builtin__\nobject\np3\nNtRp4\n.' > > >>> class C(object): #redefine C > > ...: pass > ...: > > >>> cPickle.dumps(c) #fails because the class c is an instance of no > > longer has a name. > ... > PicklingError: Can't pickle <class '__main__.C'>: it's not the same > object as __main__.C > > ----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---