[Zope] Question regarding InvalidObjectReference and the storing of objects in the session

Alec Munro alec.munro@eoascientific.com
Wed, 16 Jul 2003 16:22:43 -0300


Hi list,

I've had a system where I was storing object URLs in the session, and 
using restrictedTraverse to access the objects. I got it in my mind 
today that perhaps my knowledge of zope had expanded to the degree that 
I could figure out how to bypass this step and simply store the objects 
themselves in the session.
So I've been working on that, and pretty quickly I start to get 
InvalidObjectReference errors (I'm pretty sure they were why I chose the 
more complicated method originally). So I did some searching and I think 
I have a better understanding now of why this occurs.
The way it goes in my head is that an object in the ZODB (and possibly 
other sources) cannot be stored directly in the session.
Unfortunately, this doesn't seem to completely describe the error, as 
I've found I am sometimes able to store objects from the ZODB in the 
session. For example, here are two lines of code, in the same file, 
sequentially, with the first one working, and the second one giving me 
the InvalidObjectReference.

session['site']['current_category'] = container.site.about
#references a folder
session['center_panel'] = container.site.display_category
#references a page template

I'm 95% sure this is the area that generates the error, because I've 
commented out the areas where the objects are retrieved.

Thanks for any ideas,

Alec Munro
EOA Scientific Systems

Traceback follows ('ssh' is an internal thing)

<!--
Traceback (innermost last):
   File /usr/local/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 
150, in publish_module
   File /usr/local/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 
114, in publish
   File /usr/local/Zope-2.5.1/lib/python/Zope/__init__.py, line 159, in 
zpublisher_exception_hook
     (Object: ssh)
   File /usr/local/Zope-2.5.1/lib/python/ZPublisher/Publish.py, line 
102, in publish
   File /usr/local/Zope-2.5.1/lib/python/Zope/__init__.py, line 173, in 
commit
   File /usr/local/Zope-2.5.1/lib/python/ZODB/Transaction.py, line 234, 
in commit
   File /usr/local/Zope-2.5.1/lib/python/ZODB/Connection.py, line 346, 
in commit
     (Info: (('Products.Transience.TransientObject', 'TransientObject'), 
'\x00\x00\x00\x00\x00\x00\x006', ''))
InvalidObjectReference: (see above)

-->