On 4/5/07, paceman <[EMAIL PROTECTED]> wrote:
> One is an update_date
> that comes from
> a postgresql database

Yes, the original error reported is:
> > "/var/lib/python-support/python2.4/django/contrib/sessions/models.py",
> > line 10, in encode pickled = pickle.dumps(session_dict) PicklingError:
> > Can't pickle : it's not the same object as
> > psycopg2.tz.FixedOffsetTimezone

Which suggests that it has something to do with psycopg2. :)
Unfortunately, it looks like part of your error message was eaten.
There should be something just after "Can't pickle".  Can you send
that again?

Anyway, the datetimes returned by psycopg2 are a subclass defined in
psycopg2.  The python docs actually have a specific admonition about
pickling tzinfo:
http://www.python.org/doc/2.3.5/lib/datetime-tzinfo.html

psycopg2's tzinfo subclass implements this.

Is it possible that the tzinfo attached to the datetime you're storing
in the session is not picklable?

>>> import psycopg2

>>> c=psycopg2.connect("dbname=sekrit")

>>> cur = c.cursor()

>>> cur.execute('select current_timestamp')

>>> r = cur.fet
>>> r = cur.fetchone()

>>> r
(datetime.datetime(2007, 4, 5, 14, 46, 57, 754021,
tzinfo=<psycopg2.tz.FixedOffsetTimezone object at 0xb776bfcc>),)

>>> import pickle

>>> pickle.dumps(r)
"(cdatetime\ndatetime\np0\n(S'\\x07\\xd7\\x04\\x05\\x0e.9\\x0b\\x81e'\np1\ncpsycopg2.tz\nFixedOffsetTimezone\np2\n(tRp3\n(dp4\nS'_offset'\np5\ncdatetime\ntimedelta\np6\n(I-1\nI68400\nI0\ntp7\nRp8\nsbtp9\nRp10\ntp11\n."



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

No, that's one line in the stack trace, but it's not the line with the
error.  That line forces pickling of the session object, which is
where the problem is. It has nothing to do with the cookie.  :)

> I thought I was using straightforward django technique, except for
> using sqlalchemy to access
> my database tables.

Hmm, I have no idea how SQLAlchemy is constructing its datetime
instances. It would probably be worth looking at, since using
SQLAlchemy is probably fairly unusual with Django+psycopg2.

  -Jeremy

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

Reply via email to