Hi All,
I am using web2py 1.99.4 on Win7. I have this part of code that I
want to serialize to a view but conditionally. I am trying to retrieve
id's from one table and pass the id's to get data from another table.
Although I am able to make it work from within the loop but from
outside of the loop with "list_friend_updates=list_friend_updates", it
does not work fine. It only shows me the first entry and ignores the
rest. I think that could be a python programming problem of mine, can
any one suggest a solution?
I want that "list_friend_updates" should get all the rows I want to
iterate over. I've checked other functions and they are returning
proper values.
Here is the code from my controller -----
def home():
list_friend_updates="" #Dummy value declared to stop it showing any
issue
#Get Friends ids first
lfu = db((db.friends.reguserid == session.logged_in_user_id) &
(db.friends.status == 'Friend')).select(db.friends.friendid)
#pass the selected friendid recursively (using a for loop) and get
their updates...
for row in lfu:
#Call getfriend (see below) function below and iterate over each
id found, getfriend function returns values
list_friend_updates= getfriend(row.friendid)
print list_friend_updates #This shows all friends records and
works but fails if I use it in return below
return dict(form=form , list_friend_updates=list_friend_updates, )
##### Get Friend Function - Get the friend id values from above
function and iterate over each to get data #####
def getfriend(friendid):
friendupdates = db((db.updates.reguserid == friendid ) &
(db.updates.updated_on==now)).select()
return friendupdates
------------------------------------
What am I doing wrong? Please suggest.
Thanks,
Rahul D (www.flockbird.com) - Build Connect beta