On Thu, Jul 01, 2010 at 06:47:59PM +0000, Mark wrote:
> 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)
Why do you assign values explicitly Why not to use ForeignKey?
> subs = sorted(subs_sel, lambda x: x.topic.last_post_id)
I don't see any problem with the code. Can you write a short standalone
script that I can run to see the problem?
Oleg.
--
Oleg Broytman http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|