[SQLObject] Sorting a list of selected SQLObjects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Mark <mar...@gm...> - 2010-07-01 18:48:25
|
I just set up my own forum, and am attempting to sort a user's subscriptions by the last post in each thread(BBTopic). However the sorted function is failing saying lambda only takes 1 argument but was given 2. I use this sorted function on lists of non SQLObject objects and it works fine for me. Can you use sorted with a list returned from a select? Or is there a way for me to rewrite this? Perhaps using orderBy? subs_sel = list(BBSubs.select(BBSubs.q.user_id==1)) for sub in subs_sel: sub.topic = BBTopic.get(sub.topic_id) sub.post = BBPost.get(sub.topic.last_post_id) sub.forum = BBForum.get(sub.topic.forum_id) subs = sorted(subs_sel, lambda x: x.topic.last_post_id) |