Implementation issue: Not able to get a list of dicts (Json obj)
I am not being able to retrieve the ids and nicknames of friends when the
client tries to retrieve a location. id and nickname (along with other
content fields) stored in User table and friend relation stored in Friend
table. I am new to SQLAlchemy and python in general so any help will be
appreciated.
obj = encoders.to_json(self, Loc.LOC_JSON_ATTRS)
my_friend_ids = user.Friend.select_friend_ids(requestor_id)
friend_creators = session.query(user.User). \
join(bc.Bc). \
filter(and_(
user.User.id.in_(my_friend_ids),
requestor_id == bc.Bc.creator_id,
self.id == bc.Bc.location_id)). \
all()
obj['friend_list'] = [{'id': friend.id, 'nickname': friend.nickname} \
for friend in friend_creators]
#print obj
if not obj['friend_list']:
print "empty"
else:
obj['num_created'] = 0
obj['num_phollowing'] = 0
obj['num_collected'] = 0
obj['friend_list'] = []
No comments:
Post a Comment