Thank you LightDot, saved my day and work at the right time. Read in forums 
that redirect() is internally calling a 303 exception, but didn't realise 
that I was catching that too and redirecting to errorpage. Thanks for the 
support.

On Monday, 17 February 2014 17:02:41 UTC+5:30, LightDot wrote:
>
> Keep in mind that redirect() is an equivalent to raising an HTTP(303) 
> exception. In other words, an intentional exception is raised to create a 
> redirect.
>
> Looks like it's your own code doing a traceback and creating an error page 
> on every exception, including the cases of the intentional redirect(), 
> which is not what you want.
>
> Regards
>
>
> On Monday, February 17, 2014 8:23:57 AM UTC+1, ajith c t wrote:
>>
>> Hi Massimo, there is one more thing, it seems that the redirect problem 
>> is not only with my login function. Every function where I use a redirect 
>> call from my controller results in a error page with a log as 303 error.
>>
>> File "/srv/trustvouch-fe/applications/app/controllers/default.py", line 
>> 480, in mrtusrMgr
>>     form = crud.update(db.tv_auth_users, request.args(1), 
>> next=URL('mrtusrMgr'))
>>   File "/srv/trustvouch-fe/gluon/tools.py", line 3906, in update
>>     redirect(next)
>>   File "/srv/trustvouch-fe/gluon/http.py", line 147, in redirect
>>     Location=loc)
>> HTTP: 303 SEE OTHER
>>
>>
>> File "/srv/trustvouch-fe/applications/app/controllers/reportmgr.py", line 
>> 85, in options
>>     redirect(URL('reportmgr', 'list'))
>>   File "/srv/trustvouch-fe/gluon/http.py", line 147, in redirect
>>     Location=loc)
>> HTTP: 303 SEE OTHER
>>
>>
>>
>> On Monday, 17 February 2014 11:57:29 UTC+5:30, ajith c t wrote:
>>>
>>> Sorry Massimo,  I commented both the requires_login() and 
>>> requires_permission() for both dashboard() and my index() functions, still 
>>> the error is same.
>>>
>>> 2014-02-17 06:12:42,411 - ERROR - app - Traceback (most recent call 
>>> last):
>>>   File "/srv/trustvouch-fe/applications/app/controllers/default.py", 
>>> line 25, in login
>>>     form = auth.login()
>>>   File "/srv/trustvouch-fe/gluon/tools.py", line 2393, in login
>>>     redirect(next, client_side=settings.client_side)
>>>   File "/srv/trustvouch-fe/gluon/http.py", line 147, in redirect
>>>     Location=loc)
>>> HTTP: 303 SEE OTHER
>>>
>>> got no idea on this. 
>>>
>>> On Sunday, 16 February 2014 13:35:20 UTC+5:30, Massimo Di Pierro wrote:
>>>>
>>>> Sorry I mean here:
>>>>
>>>> @auth.requires_login()
>>>> @auth.requires_permission(request.function)
>>>> def dashboard():
>>>>
>>>> you should NOT have both. Perhaps this was causing the problem?
>>>>
>>>> On Saturday, 15 February 2014 09:15:18 UTC-6, ajith c t wrote:
>>>>>
>>>>> Hi Massimo, 
>>>>>    
>>>>>      Thanks for the reply, but sorry to say this, but I didn't 
>>>>> understand what you meant there, which function should have both. I 
>>>>> wanted 
>>>>> every user to have login and logout functions, thats why I didn't add 
>>>>> auth.permission for them.   And can you explain why it is giving 303 
>>>>> error. 
>>>>> Is it something with the redirect(next).
>>>>>
>>>>> On Thursday, 13 February 2014 18:16:27 UTC+5:30, ajith c t wrote:
>>>>>>
>>>>>>
>>>>>> Hi ,
>>>>>>   I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in my 
>>>>>> production environment. I know it is old but thinking about the mysql 
>>>>>> and 
>>>>>> other folders and files structure changes I am little hesitant to update 
>>>>>> it. My problem is this.
>>>>>>
>>>>>> My logout function doesn't work properly.  
>>>>>>
>>>>>> # Login function
>>>>>> def login():
>>>>>>   
>>>>>>   try:  
>>>>>>         logger.debug("login page")
>>>>>>         form = auth.login()
>>>>>>         return dict(form = form)
>>>>>>
>>>>>>   except Exception,e:
>>>>>>         logger.error(traceback.format_exc())
>>>>>>         redirect(URL(errorpage))
>>>>>>
>>>>>> @auth.requires_login()
>>>>>> def index():
>>>>>>
>>>>>>     try:
>>>>>>         if auth.has_membership('root'):
>>>>>>             logger.debug(auth.user.first_name + ": logged in")
>>>>>>             redirect(URL('default', 'usrMgr'))     
>>>>>>         else:
>>>>>>             logger.debug(auth.user.first_name +": logged in")   
>>>>>>
>>>>>>         redirect(URL('dashboard'))    
>>>>>>         
>>>>>>     except Exception,e:
>>>>>>         logger.error(traceback.format_exc())
>>>>>>         redirect(URL(errorpage))
>>>>>>
>>>>>> @auth.requires_login()
>>>>>> @auth.requires_permission(request.function)
>>>>>> def dashboard():
>>>>>>
>>>>>>       try:
>>>>>>             logger.info("dashboard")
>>>>>>             ###Some Code#######
>>>>>>       except Exception,e:
>>>>>>             logger.error(traceback.format_exc())
>>>>>>             redirect(URL(errorpage))
>>>>>>
>>>>>>  def logout():
>>>>>>  
>>>>>>    try:
>>>>>>          logger.debug("logout")
>>>>>>          auth.logout(next=URL(r=request, c='default', f='login'))
>>>>>>          return dict()
>>>>>>    except Exception,e:
>>>>>>          logger.error(traceback.format_exc())
>>>>>>          redirect(URL(errorpage))
>>>>>>
>>>>>>
>>>>>> The behavior is different in different browsers. In Chrome when I 
>>>>>> select logout from the dashboard page, it remains in the same page. When 
>>>>>> I 
>>>>>> select the developer tools and check the network the urls are logout, 
>>>>>> login, dashboard in order and its loaded from cache. But there is no 
>>>>>> problem in firefox.
>>>>>>
>>>>>> My problem is the logut function doesnt redirect to login page. When 
>>>>>> I clear the browser cache or delete all the sessions in the sessions 
>>>>>> folder, it works neatly. But when the session file or the cache gets 
>>>>>> filled 
>>>>>> up, everything goes wrong.  Let me know if I wasn't specific, so I can 
>>>>>> clear this problem.
>>>>>>
>>>>>> Thanks and Regards,
>>>>>>
>>>>>> Ajith
>>>>>>
>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to