le 30.09.2008 15:23 Wolverine a écrit: > Remi Jolin - SysGroup pisze: > >> why don't you simply do something like that : >> conditions = [] >> for i in (0, friends_count - 1): >> friend = friends_list[i] >> conditions.append(model.Post.account.id == friend.friend.id) >> or_clause = or_(*conditions) >> >> > > Thank you for your reply. I didn't think about this. :) However now I'm > getting: > > Module project.controllers.profile:*247* in |show_posts|: > <http://localhost:5000/_debug/view/1222772321#> > |<< <http://localhost:5000/_debug/view/1222772321#> *for* i > *in* *(**0**,* friends_count *-* *1**)**:* > friend *=* friends_list*[*i*]* > conditions*.*append*(*model*.*Post*.*account*.*id > *==* friend*.*friend*.*id*)* > or_clause *=* or_*(****conditions*)* > # evalstr = 'or_clause = or_(' > ||>> > <http://localhost:5000/_debug/view/1222772321#>conditions*.*append*(*model*.*Post*.*account*.*id > > *==* friend*.*friend*.*id*)*| > *<type 'exceptions.AttributeError'>: 'InstrumentedAttribute' object has > no attribute 'id'* > > I don't understand what it means really. Could someone explain? Does it > have something to do that model.Post.account is a relation? If so, how > should I construct this or_ clause? > > Can you post the definitions of model.Post and friend ?? If model.Post.account is a ManyToOne, you should use model.post.account_id == ...
But also, as stated Gaetan, your for loop does not seems very pythonistic... (if friends_count == len(friends_list, then a for friend in friends_list: would be better.......) > Thanks in advance, > Karol Tomala > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
