Re: [web2py] Re: detect user login

2010-11-24 Thread Richard Vézina
If I go like this :

@auth.requires_login()
def index():
*auth.messages.logged_in=T('Hello ')*
"""
Index page using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
#auth.messages.logged_in=DIV(T('Hello '),
#str(auth.user and auth.user.first_name),
#BR(),
#T('Welcome on the '),
#appTitle)
if auth.user and auth.user.first_name!=0:
response.flash
if not response.flash: response.flash = T('Hello')
return dict(message=T(''))
#return redirect(URL(request.application,'accueil','index')) # Here
redirect on app/accueil/index

I get web2py the default auth.messages.logged_in  : "connected" or something
like that.

Outside the index function it get "Hello None" user :

auth.messages.logged_in=T('Hello ')+str(auth.user and auth.user.first_name)

@auth.requires_login()
def index():
"""
Index page using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
#auth.messages.logged_in=DIV(T('Hello '),
#str(auth.user and auth.user.first_name),
#BR(),
#T('Welcome on the '),
#appTitle)
if auth.user and auth.user.first_name!=0:
response.flash
if not response.flash: response.flash = T('Hello')
return dict(message=T(''))
#return redirect(URL(request.application,'accueil','index')) # Here
redirect on app/accueil/index


Richard

On Wed, Nov 24, 2010 at 2:24 PM, Richard Vézina  wrote:

> I get :
> Hello %(first_name)s
>
> in flash response with this in default.py :
>
> auth.messages.logged_in=T('Hello %(first_name)s')#+str(auth.user and
> auth.user.first_name))
>
> @auth.requires_login()
> def index():
> """
> Index page using the internationalization operator T and flash
> rendered by views/default/index.html or views/generic.html
> """
> #auth.messages.logged_in=DIV(T('Hello '),
> #str(auth.user and auth.user.first_name),
> #BR(),
> #T('Welcome on the '),
> #appTitle)
> if auth.user and auth.user.first_name!=0:
> response.flash
> if not response.flash: response.flash = T('Hello')
> return dict(message=T(''))
>
> Richard
>
> On Wed, Nov 24, 2010 at 12:19 PM, mdipierro wrote:
>
>> What does not working mean for you?
>>
>> That is not the code I asked you to try. This does not help isolate
>> the issue since you have everything in this message (helpers, T,
>> strings, session, auth variables). Try with a simple string first.
>>
>>
>> On Nov 24, 11:09 am, Richard Vézina 
>> wrote:
>> > You meen that this, any where in controllers
>> >
>> > auth.messages.logged_in=DIV(T('Hello '),
>> > str(auth.user and auth.user.first_name),
>> > BR(),
>> > T('Welcome on the '),
>> > appTitle,
>> > session.counter)
>> >
>> > Should prompt in response.flash once at login?
>> >
>> > Not working for me...
>> >
>> > Richard
>> >
>> > On Wed, Nov 24, 2010 at 12:06 PM, mdipierro 
>> wrote:
>> > > Well be used to set the flash immediately after login. You can put it
>> > > anywere you want (models or same controller as user action) and should
>> > > work.
>> >
>> > > On Nov 24, 10:56 am, Richard Vézina 
>> > > wrote:
>> > > > How do I get the auth.messages.logged_in in response.flash only at
>> login?
>> >
>> > > > I try many different things without success.
>> >
>> > > > Is auth.messages.logged_in as to be put in auth form controller?
>> >
>> > > > On Wed, Nov 24, 2010 at 11:18 AM, mdipierro <
>> mdipie...@cs.depaul.edu>
>> > > wrote:
>> > > > > how about something like this?
>> >
>> > > > > auth.messages.logged_in=T('Hello %(first_name)s and welcome on the
>> > > > > '+appTitle')
>> >
>> > > > > def index():
>> > > > >"""
>> > > > >Index page
>> > > > >"""
>> > > > >session.counter = (session.counter or 0) + 1
>> > > > >if auth.user and auth.user.first_name!=0 and
>> session.counter<=0:
>> > > > > pass
>> > > > > elif session.counter>0:
>> > > > >pass
>> > > > >else:
>> > > > > if not response.flash: response.flash = T('Hello')
>> > > > >return dict(message=T(''))
>> >
>> > > > > On Nov 24, 10:05 am, Richard Vézina 
>> > > > > wrote:
>> > > > > > Hello
>> >
>> > > > > > I need to have a response.flash on index page at login but not
>> when
>> > > the
>> > > > > user
>> > > > > > come back on index page during a session. I try to user
>> > > session.counter
>> > > > > but
>> > > > > > the session is not reset until the cookies are erase I think.
>> >
>> > > > > > Here my index controller (*not working*) :
>> >
>> > > > > > def index():
>> > > > > > """
>> > > > > > Index page
>> > > > > > """
>> > > > > > session.counter = (session.counter or 0) + 1
>> > > > > > if auth.user and auth.user.first_name!=0 and
>> session.counter<=0:
>> > > >

Re: [web2py] Re: detect user login

2010-11-24 Thread Richard Vézina
I get :
Hello %(first_name)s

in flash response with this in default.py :

auth.messages.logged_in=T('Hello %(first_name)s')#+str(auth.user and
auth.user.first_name))

@auth.requires_login()
def index():
"""
Index page using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
#auth.messages.logged_in=DIV(T('Hello '),
#str(auth.user and auth.user.first_name),
#BR(),
#T('Welcome on the '),
#appTitle)
if auth.user and auth.user.first_name!=0:
response.flash
if not response.flash: response.flash = T('Hello')
return dict(message=T(''))

Richard

On Wed, Nov 24, 2010 at 12:19 PM, mdipierro  wrote:

> What does not working mean for you?
>
> That is not the code I asked you to try. This does not help isolate
> the issue since you have everything in this message (helpers, T,
> strings, session, auth variables). Try with a simple string first.
>
>
> On Nov 24, 11:09 am, Richard Vézina 
> wrote:
> > You meen that this, any where in controllers
> >
> > auth.messages.logged_in=DIV(T('Hello '),
> > str(auth.user and auth.user.first_name),
> > BR(),
> > T('Welcome on the '),
> > appTitle,
> > session.counter)
> >
> > Should prompt in response.flash once at login?
> >
> > Not working for me...
> >
> > Richard
> >
> > On Wed, Nov 24, 2010 at 12:06 PM, mdipierro 
> wrote:
> > > Well be used to set the flash immediately after login. You can put it
> > > anywere you want (models or same controller as user action) and should
> > > work.
> >
> > > On Nov 24, 10:56 am, Richard Vézina 
> > > wrote:
> > > > How do I get the auth.messages.logged_in in response.flash only at
> login?
> >
> > > > I try many different things without success.
> >
> > > > Is auth.messages.logged_in as to be put in auth form controller?
> >
> > > > On Wed, Nov 24, 2010 at 11:18 AM, mdipierro  >
> > > wrote:
> > > > > how about something like this?
> >
> > > > > auth.messages.logged_in=T('Hello %(first_name)s and welcome on the
> > > > > '+appTitle')
> >
> > > > > def index():
> > > > >"""
> > > > >Index page
> > > > >"""
> > > > >session.counter = (session.counter or 0) + 1
> > > > >if auth.user and auth.user.first_name!=0 and session.counter<=0:
> > > > > pass
> > > > > elif session.counter>0:
> > > > >pass
> > > > >else:
> > > > > if not response.flash: response.flash = T('Hello')
> > > > >return dict(message=T(''))
> >
> > > > > On Nov 24, 10:05 am, Richard Vézina 
> > > > > wrote:
> > > > > > Hello
> >
> > > > > > I need to have a response.flash on index page at login but not
> when
> > > the
> > > > > user
> > > > > > come back on index page during a session. I try to user
> > > session.counter
> > > > > but
> > > > > > the session is not reset until the cookies are erase I think.
> >
> > > > > > Here my index controller (*not working*) :
> >
> > > > > > def index():
> > > > > > """
> > > > > > Index page
> > > > > > """
> > > > > > session.counter = (session.counter or 0) + 1
> > > > > > if auth.user and auth.user.first_name!=0 and
> session.counter<=0:
> > > > > > response.flash = DIV(T('Hello ')+str(auth.user and
> > > > > > auth.user.first_name),BR(),T('Welcome on the '),appTitle)
> > > > > > elif session.counter>0:
> > > > > > pass
> > > > > > else:
> > > > > > response.flash = T('Hello')
> > > > > > return dict(message=T(''))
> >
> > > > > > Richard
> >
> >
>


Re: [web2py] Re: detect user login

2010-11-24 Thread Richard Vézina
Ok I found why I was redirecting to an other controller from default/index
function...

How can I replace default controller by my own "default" controller? Is it
something possible?

Richard



On Wed, Nov 24, 2010 at 12:09 PM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> You meen that this, any where in controllers
>
> auth.messages.logged_in=DIV(T('Hello '),
> str(auth.user and auth.user.first_name),
> BR(),
> T('Welcome on the '),
> appTitle,
> session.counter)
>
> Should prompt in response.flash once at login?
>
> Not working for me...
>
> Richard
>
>
>
> On Wed, Nov 24, 2010 at 12:06 PM, mdipierro wrote:
>
>> Well be used to set the flash immediately after login. You can put it
>> anywere you want (models or same controller as user action) and should
>> work.
>>
>> On Nov 24, 10:56 am, Richard Vézina 
>> wrote:
>> > How do I get the auth.messages.logged_in in response.flash only at
>> login?
>> >
>> > I try many different things without success.
>> >
>> > Is auth.messages.logged_in as to be put in auth form controller?
>> >
>> > On Wed, Nov 24, 2010 at 11:18 AM, mdipierro 
>> wrote:
>> > > how about something like this?
>> >
>> > > auth.messages.logged_in=T('Hello %(first_name)s and welcome on the
>> > > '+appTitle')
>> >
>> > > def index():
>> > >"""
>> > >Index page
>> > >"""
>> > >session.counter = (session.counter or 0) + 1
>> > >if auth.user and auth.user.first_name!=0 and session.counter<=0:
>> > > pass
>> > > elif session.counter>0:
>> > >pass
>> > >else:
>> > > if not response.flash: response.flash = T('Hello')
>> > >return dict(message=T(''))
>> >
>> > > On Nov 24, 10:05 am, Richard Vézina 
>> > > wrote:
>> > > > Hello
>> >
>> > > > I need to have a response.flash on index page at login but not when
>> the
>> > > user
>> > > > come back on index page during a session. I try to user
>> session.counter
>> > > but
>> > > > the session is not reset until the cookies are erase I think.
>> >
>> > > > Here my index controller (*not working*) :
>> >
>> > > > def index():
>> > > > """
>> > > > Index page
>> > > > """
>> > > > session.counter = (session.counter or 0) + 1
>> > > > if auth.user and auth.user.first_name!=0 and session.counter<=0:
>> > > > response.flash = DIV(T('Hello ')+str(auth.user and
>> > > > auth.user.first_name),BR(),T('Welcome on the '),appTitle)
>> > > > elif session.counter>0:
>> > > > pass
>> > > > else:
>> > > > response.flash = T('Hello')
>> > > > return dict(message=T(''))
>> >
>> > > > Richard
>> >
>> >
>>
>
>


Re: [web2py] Re: detect user login

2010-11-24 Thread Richard Vézina
You meen that this, any where in controllers

auth.messages.logged_in=DIV(T('Hello '),
str(auth.user and auth.user.first_name),
BR(),
T('Welcome on the '),
appTitle,
session.counter)

Should prompt in response.flash once at login?

Not working for me...

Richard



On Wed, Nov 24, 2010 at 12:06 PM, mdipierro  wrote:

> Well be used to set the flash immediately after login. You can put it
> anywere you want (models or same controller as user action) and should
> work.
>
> On Nov 24, 10:56 am, Richard Vézina 
> wrote:
> > How do I get the auth.messages.logged_in in response.flash only at login?
> >
> > I try many different things without success.
> >
> > Is auth.messages.logged_in as to be put in auth form controller?
> >
> > On Wed, Nov 24, 2010 at 11:18 AM, mdipierro 
> wrote:
> > > how about something like this?
> >
> > > auth.messages.logged_in=T('Hello %(first_name)s and welcome on the
> > > '+appTitle')
> >
> > > def index():
> > >"""
> > >Index page
> > >"""
> > >session.counter = (session.counter or 0) + 1
> > >if auth.user and auth.user.first_name!=0 and session.counter<=0:
> > > pass
> > > elif session.counter>0:
> > >pass
> > >else:
> > > if not response.flash: response.flash = T('Hello')
> > >return dict(message=T(''))
> >
> > > On Nov 24, 10:05 am, Richard Vézina 
> > > wrote:
> > > > Hello
> >
> > > > I need to have a response.flash on index page at login but not when
> the
> > > user
> > > > come back on index page during a session. I try to user
> session.counter
> > > but
> > > > the session is not reset until the cookies are erase I think.
> >
> > > > Here my index controller (*not working*) :
> >
> > > > def index():
> > > > """
> > > > Index page
> > > > """
> > > > session.counter = (session.counter or 0) + 1
> > > > if auth.user and auth.user.first_name!=0 and session.counter<=0:
> > > > response.flash = DIV(T('Hello ')+str(auth.user and
> > > > auth.user.first_name),BR(),T('Welcome on the '),appTitle)
> > > > elif session.counter>0:
> > > > pass
> > > > else:
> > > > response.flash = T('Hello')
> > > > return dict(message=T(''))
> >
> > > > Richard
> >
> >
>


Re: [web2py] Re: detect user login

2010-11-24 Thread Richard Vézina
How do I get the auth.messages.logged_in in response.flash only at login?

I try many different things without success.

Is auth.messages.logged_in as to be put in auth form controller?

On Wed, Nov 24, 2010 at 11:18 AM, mdipierro  wrote:

> how about something like this?
>
> auth.messages.logged_in=T('Hello %(first_name)s and welcome on the
> '+appTitle')
>
> def index():
>"""
>Index page
>"""
>session.counter = (session.counter or 0) + 1
>if auth.user and auth.user.first_name!=0 and session.counter<=0:
> pass
> elif session.counter>0:
>pass
>else:
> if not response.flash: response.flash = T('Hello')
>return dict(message=T(''))
>
> On Nov 24, 10:05 am, Richard Vézina 
> wrote:
> > Hello
> >
> > I need to have a response.flash on index page at login but not when the
> user
> > come back on index page during a session. I try to user session.counter
> but
> > the session is not reset until the cookies are erase I think.
> >
> > Here my index controller (*not working*) :
> >
> > def index():
> > """
> > Index page
> > """
> > session.counter = (session.counter or 0) + 1
> > if auth.user and auth.user.first_name!=0 and session.counter<=0:
> > response.flash = DIV(T('Hello ')+str(auth.user and
> > auth.user.first_name),BR(),T('Welcome on the '),appTitle)
> > elif session.counter>0:
> > pass
> > else:
> > response.flash = T('Hello')
> > return dict(message=T(''))
> >
> > Richard
>