I've this peace of code working well but I need to sort_on de object property "texto", but I cann't access this properties on the portal_catalog.searchResults, anyone can help me please?
First you need to make sure your texto property is indexed:
Go to your Plone ZMI, then portal_catalog, then Indexes (url similar to: http://localhost:8080/Plone/portal_catalog/manage_catalogIndexes ).
If textto is not in the list, it means it is not indexed so you cannot use it in search or sorting.
If it is in the list but its index type is ZCTextIndex or KeyworkIndex, then you cannot use for sorting (you probably need a FieldIndex).
But now you should not call item/getObject anymore because item is already the object. You should replace all item_obj.getProperty(...) with item.getProperty(...).
Ideally you should have it in your browser's view class but yes, it should work where it is (note you can remove getURL and getId references since those are related to brains only). Only item/getObject won't make sense (i.e. will throw an error) since each item will already be the object.
Please test the code and make the needed fixes by reading the links in this thread. Only then you'll understand all you need to do.
Module Products.PageTemplates.ZRPythonExpr, line 48, in call traceback_info: sorted([brain.getObject() for brain in results], key=lambda obj:obj.texto) Module PythonExpr, line 1, in
NameError: name 'sorted' is not defined
As I said, untested code But probably a good pointer so try to move your logic to a browser view and from there you should be able to more easily debug (with pdb) what's wrong.
Again, untested, but I might have realized why nothing appeared. Unlike sorted(), the list.sort method works inplace so nothing was set in the objs variable. You could try:
tal:define="...;
objs python:[brain.getObject() for brain in results];
dummy python:objs.sort(key=texto)">