Hi, I don't undertand !!!
I create a simple python script with "return context.objectValues()"
Systematically, I have a error
This is a traceback:
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 359, in publish_module
Module ZPublisher.WSGIPublisher, line 264, in publish
Module ZPublisher.HTTPResponse, line 1098, in setBody
Module ZPublisher.HTTPResponse, line 528, in setBody
AttributeError: index
I tried this script into zope2, and no problem. What is happening !
can someone explain to me why Zope4 is so different from Zope2? Is this a difference induced by the version of python?
In fact there is a problem. If we try to directly return a list of objects we get an error, on the other hand if we return a list of id of objects it works.
Works:
results=
datas = context.objectValues(['Page Template'])
for obj in datas:
if obj.getProperty('published'):
results.append(obj.id)
return results
But not this:
results=
datas = context.objectValues(['Page Template'])
for obj in datas:
if obj.getProperty('published'):
results.append(obj)
return results
Zope objects are very complex -- too complex that the response could directly handle it. That''s why return f.objectValues() fails while return f.objectIds() works.
That was the missing link. The return statement in a Script(Python) directly generates a response!
As of the differences between Zope 2 and Zope 4... I do not know whether this is relevant here, but I noticed that __repr__ of my Zope objects has changed, from something useful, to something , so I had to create custom __repr__ for all my classes.