Use auth.user_id instead. def index(): if auth.is_logged_in(): redirect(URL('profile', 'member',args=auth.user_id))
On Wednesday, November 21, 2012 12:24:17 PM UTC+8, Don_X wrote: > > In an app where users have their own profile page ! > Once a user gets logged in with their credentials .. they get redirected > to their own profile page with all of their edit functions and preferences > etc ... ... OK ! all was good so far ... BUT > > when the user is browsing through the app, I want that same user to be > able to view other users' profile pages... if he wants to . ! > so I am tweaking my previous function to do that without having to > replicate the same profile page so the logged in user can view other > users'profile page ! > > so I have a setup similar to this now : > > the user gets logged in and that user gets redirected to > ('profile','index') i.e. ( controller, function ) > in the profile.py controller, I have set up a new function index is as > follows : > def index(): > redirect(URL('profile', 'member',args=' ')) > > Where the args, which is empty by default at first, would be the user's id > ! > > ( that way : all links to other user's profile would be written like : > {{=URL('profile','member',args=auth_user.id <http://auth_user.id>)}} on > any given page for any given user listed with their respective ids on the > site ) > > now, I am having some trouble with the member function > basically, I want this member function to do the following : > > if the logged in user id is the same as args then return the logged in > user row ( member ) > if not then return the row of the user id equal to args (member) from the > database > > and obviously, in the profile page itself, I will do validation such as if > member == to loggged in user then they can edit, do stuff they can do on > their own profile etc ... and if not ... then they cannot edit that other > user's profile's etc ... > > you get the idea ! so : ... I am not sure if my logic is fine through > these lines of python code for that member function : > > def member(): > response.view = 'profile/index.html' > member = session.get("auth",{}) > if member.id == auth_user[args] : > return dict(member=member) > else : > for row in db(db.auth_user.id == args).select(): > member = row > return dict(member=member) > > > I would think it would work .. but does not ! ... Can any one can > enlighten me with this !! > > thank you > > Don > > --