[Zope] __bobo_traverse__ (Cont.)
Garito
garito at sistes.net
Tue Aug 31 07:28:04 EDT 2004
Hi
In my last mail I ask you (thanks for your responses) about an error
publishing the object in __bobo_traverse__
The solution passes by returning an object instead a string (I would
like to return a string :( )
Then my __bobo_traverse__ is something like:
def __bobo_traverse__(self, REQUEST, name):
obj = getattr(self, name, None)
if obj is not None:
return obj
else:
return getattr(self, 'Result')
But I need to process some information in bobo_traverse before returns
Result
If you change the line return getattr(self, 'Result') for return
getattr(self, 'Result')('someresults') doesn't work
For that I need to do something like:
_Results = dict() # I put these declaration in my class
def __bobo_traverse__(self, REQUEST, name):
obj = getattr(self, name, None)
if obj is not None:
return obj
else:
self._Results[str(REQUEST.SESSION.id)] = self.MyResult()
return getattr(self, 'Result')
def MyResult(self):
"""MyResult"""
return 'This is my test result'
def GetResults(self, Session):
""" GetResults"""
return self._Results[str(Session)]
Then I create a Python Script called Result like:
return context.GetResults(context.REQUEST.SESSION.id)
But all these code raise:
Traceback (innermost last):
Module ZPublisher.Publish, line 91, in publish
Module ZPublisher.BaseRequest, line 302, in traverse
Module Products.MyProducts.MyProduct, line 116, in __bobo_traverse__
TypeError: object does not support item assignment
I can't undersand why can't I assign a dictionary. I can understand if I
try to assign a number like dictionary key (but I convert the session id
to a string)
Some ideas?
THANKS AGAIN!
More information about the Zope
mailing list