Is there a way to do a dynamic sort= on a dtml-in on a list of dictionaries? like: <dtml-call "REQUEST.set('sortby', 'firstname')"> <dtml-in "queryname_py" mapped sort=_['sortby']> etc... I've tried _['sortby'], _[sortby], "_['sortby']", and "_[sortby]" and I always get an error. Is there an easy way to do this? Thanks, Rick
Check sequence.sort(). Docs are in the API refs. -aj --On Montag, 13. Oktober 2003 10:16 Uhr -0700 "D. Rick Anderson" <ruger@acsnv.com> wrote:
Is there a way to do a dynamic sort= on a dtml-in on a list of dictionaries?
like:
<dtml-call "REQUEST.set('sortby', 'firstname')">
<dtml-in "queryname_py" mapped sort=_['sortby']> etc...
I've tried _['sortby'], _[sortby], "_['sortby']", and "_[sortby]" and I always get an error. Is there an easy way to do this?
Thanks,
Rick
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
OK .. sorry for the hand-holding here, but the syntax of this doesn't make sense to me. If I try: _.sequence.sort(sequencename, 'lname', 'asc') where sequencename is a python script that returns a list of dictionaries and lname is the name of a key in those dictionaries that I wish to sort by. Then it doesn't barf, but it doesn't sort either. if I use: _.sequence.sort(sequencename, (('lname', 'asc'),)) Which is imitating the syntax from the Zope Book, then it barfs with: Attribute Error: 'None' has no object 'getitem' so ... I guess the question here is, What is the correct syntax to make this work? Thanks so much for your help, Rick Andreas Jung wrote:
Check sequence.sort(). Docs are in the API refs.
-aj
--On Montag, 13. Oktober 2003 10:16 Uhr -0700 "D. Rick Anderson" <ruger@acsnv.com> wrote:
Is there a way to do a dynamic sort= on a dtml-in on a list of dictionaries?
like:
<dtml-call "REQUEST.set('sortby', 'firstname')">
<dtml-in "queryname_py" mapped sort=_['sortby']> etc...
I've tried _['sortby'], _[sortby], "_['sortby']", and "_[sortby]" and I always get an error. Is there an easy way to do this?
Thanks,
Rick
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
According to the documentation* what you want is 'sort_expr='. I do however recommend you stop using DTML alltogether. Stefan *<http://zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixA.stx> --On Montag, 13. Oktober 2003 10:16 -0700 "D. Rick Anderson" <ruger@acsnv.com> wrote:
Is there a way to do a dynamic sort= on a dtml-in on a list of dictionaries?
like:
<dtml-call "REQUEST.set('sortby', 'firstname')">
<dtml-in "queryname_py" mapped sort=_['sortby']> etc...
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
That did it! Thank you! I have very few compelling reasons to change to ZPT at this point, and it would actually be a small disaster to attempt it. I have 6 very large reporting sites built entirely on DTML that have been running for over 2 years now that way. It would be a major undertaking to overhaul them to ZPT, not to mention the fact that there would be a learning curve while I was trying to figure out how to get all of what I had working to work with templates. The other issue is that neither myself, nor our web designer uses a GUI page builder. He hand codes everything right through the Zope interface, as do I. I've learned to keep the business logic well seperated from the design elements, so I really don't have a strong reason to jump, especially since I'm so comfortable with DTML. Thanks for your help, Rick Stefan H. Holek wrote:
According to the documentation* what you want is 'sort_expr='. I do however recommend you stop using DTML alltogether.
Stefan
*<http://zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixA.stx>
--On Montag, 13. Oktober 2003 10:16 -0700 "D. Rick Anderson" <ruger@acsnv.com> wrote:
Is there a way to do a dynamic sort= on a dtml-in on a list of dictionaries?
like:
<dtml-call "REQUEST.set('sortby', 'firstname')">
<dtml-in "queryname_py" mapped sort=_['sortby']> etc...
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
participants (3)
-
Andreas Jung -
D. Rick Anderson -
Stefan H. Holek