Complex <dtml-in> query sorting
Hi, I have to use a <dtml-in> code to handle a quite complex thing : - I have an SQL method, which retrieves an object OID ; this OID is a globally unique identifier, which is cataloged and used in all my objects. - I have a Zope method at my site root, called "getObject(oid)", which for a given OID retrieve the corresponding Zope object - each object also have a custom method called "getSortValue()" which retrieves a sort value !! My code (in a DTML method) is like : <dtml-in "[getObject(record['oid']) for record in sql_method(params)]" sort_expr="getSortValue()"> The <dtml-in> loop works well and retrieves my object, but the "sort_expr" attribute doesn't work and so results are not sorted ; it seems that "getSortValue()" is not called on the good object... What should I have to do for this to work ??? Thanks for any help, Thierry -- Linux every day, keeps Dr Watson away... http://gpc.sourceforge.net -- http://www.ulthar.net
Thierry FLORAC wrote:
My code (in a DTML method) is like :
<dtml-in "[getObject(record['oid']) for record in sql_method(params)]" sort_expr="getSortValue()">
The <dtml-in> loop works well and retrieves my object, but the "sort_expr" attribute doesn't work and so results are not sorted ; it seems that "getSortValue()" is not called on the good object...
As far as I know sort_expr in dtml-in means: evaluate the expression and use the result as sort-key. So if you have a variable skey in your namespace and use <dtml-in ... sort_expr="skey"> you get different sortings depending on the value of skey (title, id, ...). You need an already sorted sequence. See ZopeHelp->ApiReference->sequence. -mj
participants (3)
-
Dieter Maurer -
Maik Jablonski -
Thierry FLORAC