[Zope] store dict in session
Dennis Schulz
d.schulz81 at gmx.net
Wed Jan 10 10:31:17 EST 2007
According to the zope book it should be possible to store dicts in session.
When I try to assign a dictionary to a ordinary zope 2 session, with
lists there is no problem. why?:
requestlist = {}
for i in self.request.form:
key = i
value = self.request.form[i]
requestlist[i] = self.request.form[i]
sess = self.context.REQUEST.SESSION
sess['pr_reqlist'] = requestlist
I get the following error:
Traceback (innermost last):
* Module ZPublisher.Publish, line 196, in publish_module_standard
* Module Products.PlacelessTranslationService.PatchStringIO, line
34, in new_publish
* Module ZPublisher.Publish, line 146, in publish
* Module Zope2.App.startup, line 222, in zpublisher_exception_hook
* Module ZPublisher.Publish, line 121, in publish
* Module Zope2.App.startup, line 240, in commit
* Module transaction._manager, line 96, in commit
* Module transaction._transaction, line 380, in commit
* Module transaction._transaction, line 378, in commit
* Module transaction._transaction, line 433, in _commitResources
* Module ZODB.Connection, line 484, in commit
* Module ZODB.Connection, line 526, in _commit
* Module ZODB.Connection, line 553, in _store_objects
* Module ZODB.serialize, line 407, in serialize
* Module ZODB.serialize, line 416, in _dump
* Module copy_reg, line 69, in _reduce_ex
TypeError: can't pickle instancemethod objects (Also, the following
error occurred while attempting to render the standard error message,
please see the event log for full details: An operation previously
failed, with traceback: File
"C:\Python\Zope\Zope\lib\python\ZServer\PubCore\ZServerPublisher.py",
line 23, in __init__ response=response) File
"C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line
395, in publish_module environ, debug, request, response) File
"C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line
196, in publish_module_standard response = publish(request, module_name,
after_list, debug=debug) File
"C:\Python\Zope\Instance\Products\PlacelessTranslationService\PatchStringIO.py",
line 34, in new_publish x = Publish.old_publish(request, module_name,
after_list, debug) File
"C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line
121, in publish transactions_manager.commit() File
"C:\Python\Zope\Zope\lib\python\Zope2\App\startup.py", line
240, in commit transaction.commit() File
"C:\Python\Zope\Zope\lib\python\transaction\_manager.py", line
96, in commit return self.get().commit(sub, deprecation_wng=False) File
"C:\Python\Zope\Zope\lib\python\transaction\_transaction.py",
line 380, in commit self._saveCommitishError() # This raises! File
"C:\Python\Zope\Zope\lib\python\transaction\_transaction.py",
line 378, in commit self._commitResources() File
"C:\Python\Zope\Zope\lib\python\transaction\_transaction.py",
line 433, in _commitResources rm.commit(self) File
"C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 484,
in commit self._commit(transaction) File
"C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 526,
in _commit self._store_objects(ObjectWriter(obj), transaction) File
"C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 553,
in _store_objects p = writer.serialize(obj) # This calls __getstate__ of
obj File "C:\Python\Zope\Zope\lib\python\ZODB\serialize.py",
line 407, in serialize return self._dump(meta, obj.__getstate__()) File
"C:\Python\Zope\Zope\lib\python\ZODB\serialize.py", line 416,
in _dump self._p.dump(state) File
"C:\Python\Zope\Python\lib\copy_reg.py", line 69, in
_reduce_ex raise TypeError, "can't pickle %s objects" %
base.__name__ TypeError: can't pickle instancemethod objects )
More information about the Zope
mailing list