Session and objects
Hello, all. I would like to handle session events. For example: user closes browser, etc. Seems that is not possible, so I desire do it via the Session. But... is it possible to add somethin non-string'ish into the SESSION? For example, I would like add the an DB connecton or DB cursor or any other object. But Zope tells me something like: Error Type: InvalidObjectReference Error Value: Attempt to store an object from a foreign database connection Traceback (innermost last): File /opt/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module File /opt/zope/lib/python/ZPublisher/Publish.py, line 114, in publish File /opt/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook (Object: storedProcedure) File /opt/zope/lib/python/ZPublisher/Publish.py, line 102, in publish File /opt/zope/lib/python/Zope/__init__.py, line 173, in commit File /opt/zope/lib/python/ZODB/Transaction.py, line 234, in commit File /opt/zope/lib/python/ZODB/Connection.py, line 346, in commit (Info: (('Products.Transience.TransientObject', 'TransientObject'), '\x00\x00\x00\x00\x00\x00\x00\x0b', '')) InvalidObjectReference: (see above) Is here some workaround or advantage? -- Regards, Bogdan BASIC: A programming language. Related to certain social diseases in that those who have it will not admit it in polite company.
(Please wrap your text at 72 columns, thank you) On Mon, Sep 30, 2002 at 12:43:49PM +0200, Bogdan M.Maryniuck wrote:
I would like to handle session events. For example: user closes browser, etc. Seems that is not possible, so I desire do it via the Session. But... is it possible to add somethin non-string'ish into the SESSION? For example, I would like add the an DB connecton or DB cursor or any other object.
I think you have to use pickleable objects, though I'm not 100% sure. I had no problems at all with Python lists and ints.
Is here some workaround or advantage?
Try storing an id instead of the object itself. Marius Gedminas -- Cheap, Fast, Good -- pick two.
Hi Bodgan, I had the same problem as long as I used python-scripts to store objects in the SESSION-data. Now I transferred my project to a product and now it's possible to store self-defined objects in the SESSION-data. But I don't know why ... Ulla. "Bo M. Maryniuck" schrieb:
Hello, all.
I would like to handle session events. For example: user closes browser, etc. Seems that is not possible, so I desire do it via the Session. But... is it possible to add somethin non-string'ish into the SESSION? For example, I would like add the an DB connecton or DB cursor or any other object. But Zope tells me something like:
Error Type: InvalidObjectReference Error Value: Attempt to store an object from a foreign database connection
Traceback (innermost last): File /opt/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module File /opt/zope/lib/python/ZPublisher/Publish.py, line 114, in publish File /opt/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook (Object: storedProcedure) File /opt/zope/lib/python/ZPublisher/Publish.py, line 102, in publish File /opt/zope/lib/python/Zope/__init__.py, line 173, in commit File /opt/zope/lib/python/ZODB/Transaction.py, line 234, in commit File /opt/zope/lib/python/ZODB/Connection.py, line 346, in commit (Info: (('Products.Transience.TransientObject', 'TransientObject'), '\x00\x00\x00\x00\x00\x00\x00\x0b', '')) InvalidObjectReference: (see above)
Is here some workaround or advantage?
-- Regards, Bogdan
BASIC: A programming language. Related to certain social diseases in that those who have it will not admit it in polite company.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Monday 30 September 2002 13:10, Ulla Theiss wrote:
Now I transferred my project to a product and now it's possible to store self-defined objects in the SESSION-data. But I don't know why ...
What You mean "SESSION-data"? I still can't do something like: session = request['SESSION'] session['foo'] = context.da.connect(...) # Make error here ...nor in PyScript neither in product and always got the same error. OTOH, the object should be pickleable... :/ -- Regards, Bogdan A witty saying proves nothing. -- Voltaire
you cannot directly store a zope object that is already stored in the normal ZODB. the sessioning "storage" is considered a different database by zope and you cannot store an object in more than one zope database. what you can do is "clone" the object you are trying to store and then store it in the session. you must make sure whatever you are storing in the session has no references in the "real" ZODB. i'm not sure what you are trying to achieve here. it is always the easiest to store nothing but simple python data types (strings, sequences, dictionaries) in a session data container. a much better solution might be to store something that acts as a "key" and lets you find what you need in the real ZODB when you need it. jens On Monday, Sep 30, 2002, at 06:43 US/Eastern, Bo M. Maryniuck wrote:
Hello, all.
I would like to handle session events. For example: user closes browser, etc. Seems that is not possible, so I desire do it via the Session. But... is it possible to add somethin non-string'ish into the SESSION? For example, I would like add the an DB connecton or DB cursor or any other object. But Zope tells me something like:
Error Type: InvalidObjectReference Error Value: Attempt to store an object from a foreign database connection
Traceback (innermost last): File /opt/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module File /opt/zope/lib/python/ZPublisher/Publish.py, line 114, in publish File /opt/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook (Object: storedProcedure) File /opt/zope/lib/python/ZPublisher/Publish.py, line 102, in publish File /opt/zope/lib/python/Zope/__init__.py, line 173, in commit File /opt/zope/lib/python/ZODB/Transaction.py, line 234, in commit File /opt/zope/lib/python/ZODB/Connection.py, line 346, in commit (Info: (('Products.Transience.TransientObject', 'TransientObject'), '\x00\x00\x00\x00\x00\x00\x00\x0b', '')) InvalidObjectReference: (see above)
Is here some workaround or advantage?
-- Regards, Bogdan
BASIC: A programming language. Related to certain social diseases in that those who have it will not admit it in polite company.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Bo M. Maryniuck -
Jens Vagelpohl -
Marius Gedminas -
Ulla Theiss