Please follow lyn2py's answer and you will be on the right track.

def index():
   if auth.is_logged_in():
       redirect(URL('profile', 'member', args=auth.user_id))

@auth.requires_login()
def member():
       if int(request.args(0)) == auth.user_id:
            print 'profile of connected member'
       else:
            print 'profile of an other member'
       return locals()


Il giorno giovedì 22 novembre 2012 03:48:46 UTC+1, Don_X ha scritto:
>
> Thank you lyn2py ...
>>
>
> Unfortunately, your proposition does not work !
>
> In this situation,  I wanted to practice the DRY principal ( DONT REAPEAT 
> YOURSELF ) ... but it seems  ( based on my limited knowledge  ) 
> the only way that I succeeded was in duplicating the exact same view page 
> of index.html and named it member.html and offcourse by passing  the  
> dictionnary membr as argument in order to view other 
> members of the site
>
> I did it like this :  ( it is very simplist ... but it is the only way I 
> got it to work ! ) 
> The profile.py controller has :
> @auth.requires_login()
> def index():
>    return dict()
>    
> def member():
>     for row in db(db.auth_user.id == db.auth_user(request.args(0))).select
> ():
>         membr = row          
>     return dict(membr=membr)
>
> that way, when the user gets logged in, that user goes to his profile page 
> at profile/index.html and can edit and manage his own profile etc ...
>
> and when any other user wishes to simply view someone's else profile page  
> they get to go to  profile/member/#    where the # is the user id of that 
> member and not edit possible .. just comments on that user's wall can be 
> made or to look around based on that user's personal preferences etc ...
>
> I wanted to have one single view page  ... but .. hey ... I guess I will 
> have to settle for this scenario for the time being ... until I come up 
> with another way to have one view page for both actions !
>
> Don
>

-- 



Reply via email to