Re: [web2py] Re: login after period of inactivity

2020-05-06 Thread Jim Steil
Can you share the code for the user function in default.py?

How do you know that the session timed out?

Jim


On Wed, May 6, 2020, 5:58 PM Maurice Waka  wrote:

> After clicking the login, that's when the error comes in.
> No I haven't set the timer. I left the same time length in default.
> Kind regards
>
> On Wed, May 6, 2020 at 3:58 PM Jim S  wrote:
>
>> You said you notice this message after a period of inactivity, but you
>> also say this message comes up after clicking login.  What is telling you
>> that this is happening after a period of inactivity?
>>
>> I was hoping to see what you have for default/user/load (which you
>> referenced above) - load is not a built-in function in default/user that
>> I'm aware of.
>>
>> Here is the normal default/user signature:
>>
>>
>> def user():
>> """
>> exposes:
>> http:///[app]/default/user/login
>> http:///[app]/default/user/logout
>> http:///[app]/default/user/register
>> http:///[app]/default/user/profile
>> http:///[app]/default/user/retrieve_password
>> http:///[app]/default/user/change_password
>> use @auth.requires_login()
>> @auth.requires_membership('group name')
>> @auth.requires_permission('read','table name',record_id)
>> to decorate functions that need access control
>> """
>>
>> So I was thinking you had put something custom in there.
>>
>> Are you able to force it to happen by setting your
>> auth.settings.expiration to a low number of seconds?
>>
>> -Jim
>>
>>
>> On Wednesday, May 6, 2020 at 12:11:55 AM UTC-5, Maurice Waka wrote:
>>>
>>> Actually, I want to customize the code to get better feedback, and after
>>> digging in I got this discussion
>>> 
>>>
>>> I just don't know where to exactly place this code, or get something
>>> better:
>>>
>>> auth.messages.ajax_failed_authentication = DIV(H4(T('Your session has 
>>> expired')),
>>> T('Please '),
>>> A(T('login'),
>>>   _href=auth.settings.login_url +
>>> ('?_next=' + 
>>> urllib.quote(request.env.http_web2py_component_location))
>>>   if request.env.http_web2py_component_location 
>>> else ''),
>>> T(' again to view this content.'),
>>> _class='not-authorized alert alert-block')
>>>
>>>
>>>
>>> On Tue, May 5, 2020 at 11:09 PM Jim S  wrote:
>>>
 Can you show some code?

 -Jim

 On Tuesday, May 5, 2020 at 1:38:29 PM UTC-5, Maurice Waka wrote:
>
> I notice this message after a period of inactivity. See attached.
> The problem is that on clicking on the login link on the app on
> pythonanywhere, I get an error: invalid view (default/user/load).
> How can I resolve this?
> Regards
>
 --
 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 a topic in the
 Google Groups "web2py-users" group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/Px0b1zYX-Zg/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/web2py/541b05b3-02b7-4bc8-8773-f093a41bc1ce%40googlegroups.com
 
 .

>>> --
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/Px0b1zYX-Zg/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/badaa3f7-1281-412d-81a0-6b053adb8040%40googlegroups.com
>> 
>> .
>>
> --
> 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 a topic in the
> Google Groups "web2py-users" 

Re: [web2py] Re: login after period of inactivity

2020-05-06 Thread Maurice Waka
After clicking the login, that's when the error comes in.
No I haven't set the timer. I left the same time length in default.
Kind regards

On Wed, May 6, 2020 at 3:58 PM Jim S  wrote:

> You said you notice this message after a period of inactivity, but you
> also say this message comes up after clicking login.  What is telling you
> that this is happening after a period of inactivity?
>
> I was hoping to see what you have for default/user/load (which you
> referenced above) - load is not a built-in function in default/user that
> I'm aware of.
>
> Here is the normal default/user signature:
>
>
> def user():
> """
> exposes:
> http:///[app]/default/user/login
> http:///[app]/default/user/logout
> http:///[app]/default/user/register
> http:///[app]/default/user/profile
> http:///[app]/default/user/retrieve_password
> http:///[app]/default/user/change_password
> use @auth.requires_login()
> @auth.requires_membership('group name')
> @auth.requires_permission('read','table name',record_id)
> to decorate functions that need access control
> """
>
> So I was thinking you had put something custom in there.
>
> Are you able to force it to happen by setting your
> auth.settings.expiration to a low number of seconds?
>
> -Jim
>
>
> On Wednesday, May 6, 2020 at 12:11:55 AM UTC-5, Maurice Waka wrote:
>>
>> Actually, I want to customize the code to get better feedback, and after
>> digging in I got this discussion
>> 
>>
>> I just don't know where to exactly place this code, or get something
>> better:
>>
>> auth.messages.ajax_failed_authentication = DIV(H4(T('Your session has 
>> expired')),
>> T('Please '),
>> A(T('login'),
>>   _href=auth.settings.login_url +
>> ('?_next=' + 
>> urllib.quote(request.env.http_web2py_component_location))
>>   if request.env.http_web2py_component_location 
>> else ''),
>> T(' again to view this content.'),
>> _class='not-authorized alert alert-block')
>>
>>
>>
>> On Tue, May 5, 2020 at 11:09 PM Jim S  wrote:
>>
>>> Can you show some code?
>>>
>>> -Jim
>>>
>>> On Tuesday, May 5, 2020 at 1:38:29 PM UTC-5, Maurice Waka wrote:

 I notice this message after a period of inactivity. See attached.
 The problem is that on clicking on the login link on the app on
 pythonanywhere, I get an error: invalid view (default/user/load).
 How can I resolve this?
 Regards

>>> --
>>> 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 a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/web2py/Px0b1zYX-Zg/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/541b05b3-02b7-4bc8-8773-f093a41bc1ce%40googlegroups.com
>>> 
>>> .
>>>
>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Px0b1zYX-Zg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/badaa3f7-1281-412d-81a0-6b053adb8040%40googlegroups.com
> 
> .
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CALkNK54dFiuG9YNKyLw5%3DeGQCZx7%2ByacSk%3Dn-aMLtjcOAq1yGQ%40mail.gmail.com.


[web2py] Re: web2py - date picker issue

2020-05-06 Thread Scott Hunter
Please identify what part of this rather long file is relevant to your 
question.  You might also want to look at the documentation for SQLFORM 
with regard ti how to use keepvalues.

On Wednesday, May 6, 2020 at 9:44:37 AM UTC-4, Anuj Mahawar wrote:
>
> Yes, its part of the SQLFORM. I have attached my file from the controller. 
> Could you please let me know where do I need to make the changes (i.e. 
> keepvalues = True)
>
> Regards,
> Anuj
>
> On Tuesday, May 5, 2020 at 6:38:29 PM UTC+5:30, Scott Hunter wrote:
>>
>> If this is part of a form (which I have to guess at, since you have 
>> provided *no* details), you can use the `keepvalues` option to not reset 
>> the fields of a form.
>>
>> On Tuesday, May 5, 2020 at 8:24:32 AM UTC-4, Anuj Mahawar wrote:
>>>
>>> Hey Scott, 
>>> Yeah, I meant that the date is resetting to the current date even though 
>>> I am selecting any previous date. Do you have any suggestions to change 
>>> this default behavior?
>>>
>>> On Tuesday, May 5, 2020 at 5:22:30 PM UTC+5:30, Scott Hunter wrote:

 What do you mean by "redirected"?  If you just mean that the date field 
 is reset to the current date, that is the same default behavior for all 
 input fields.

 On Tuesday, May 5, 2020 at 12:44:31 AM UTC-4, Anuj Mahawar wrote:
>
> I am a beginner to the web2py. I am building an application with a 
> date picker on the home page. The issue is - Whenever I try to edit a 
> previous day's record and submit, instead of on being on the same date, 
> it 
> is being redirected to the current date page. e.g. suppose I have logged 
> in 
> and it displays the current date i.e. 29 April 2020. When I try to edit a 
> record for 01 April 2020 and submit the entry, it is being redirected to 
> the current date i.e. 29 April 2020. Any idea why the application is 
> behaving like that?
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d77ee4d0-7c07-42db-bd9c-3715e947b935%40googlegroups.com.


[web2py] Re: web2py - date picker issue

2020-05-06 Thread Anuj Mahawar
Yes, its part of the SQLFORM. I have attached my file from the controller. 
Could you please let me know where do I need to make the changes (i.e. 
keepvalues = True)

Regards,
Anuj

On Tuesday, May 5, 2020 at 6:38:29 PM UTC+5:30, Scott Hunter wrote:
>
> If this is part of a form (which I have to guess at, since you have 
> provided *no* details), you can use the `keepvalues` option to not reset 
> the fields of a form.
>
> On Tuesday, May 5, 2020 at 8:24:32 AM UTC-4, Anuj Mahawar wrote:
>>
>> Hey Scott, 
>> Yeah, I meant that the date is resetting to the current date even though 
>> I am selecting any previous date. Do you have any suggestions to change 
>> this default behavior?
>>
>> On Tuesday, May 5, 2020 at 5:22:30 PM UTC+5:30, Scott Hunter wrote:
>>>
>>> What do you mean by "redirected"?  If you just mean that the date field 
>>> is reset to the current date, that is the same default behavior for all 
>>> input fields.
>>>
>>> On Tuesday, May 5, 2020 at 12:44:31 AM UTC-4, Anuj Mahawar wrote:

 I am a beginner to the web2py. I am building an application with a date 
 picker on the home page. The issue is - Whenever I try to edit a previous 
 day's record and submit, instead of on being on the same date, it is being 
 redirected to the current date page. e.g. suppose I have logged in and it 
 displays the current date i.e. 29 April 2020. When I try to edit a record 
 for 01 April 2020 and submit the entry, it is being redirected to the 
 current date i.e. 29 April 2020. Any idea why the application is behaving 
 like that?



-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/197d1e24-a50d-4ec8-b6a5-a517beed0f04%40googlegroups.com.
# -*- coding: utf-8 -*-
# -
# This is a sample controller
# this file is released under public domain and you can use without limitations
# -

#  example index page 
def index():
if not session.logged_in_user:
redirect(URL('login'))
import datetime
form=SQLFORM(db.ts_date,buttons=[])
for row in form.element('table'): del row[0]
message = pull_home_data()

#except Exception,e:
   # response.flash='Something wrong! '+str(e)
return locals()

def pull_home_data():
if not session.logged_in_user:
redirect(URL('login'))
import datetime
date = ''
message=''
ts_data=''
html = ''
userid = session.user_id
inst_prod=''
sum_time=datetime.timedelta()
if 1:
if request.post_vars.date:
date = date=datetime.datetime.strptime(request.post_vars.date,"%d %B %Y").date()
else:
date = request.now
ts_data = db((db.ts_data.date_worked == date) & (db.ts_data.username==userid)).select(db.ts_data.id,db.ts_data.product_Name,db.ts_data.time_worked,db.ts_data.comments,db.ts_data.date_worked,orderby=db.ts_data.id)
if ts_data:
total_time = [str(x['time_worked']) for x in ts_data]
for y in total_time:
(h, m, s) = y.split(':')
d = datetime.timedelta(hours=int(h), minutes=int(m))
sum_time += d
html += 'Total Hours Worked '+str(sum_time)[:-3]+''
ts_prod = list(set(row['product_Name'] for row in ts_data))
for row in ts_prod:
sum_ptime = datetime.timedelta()
total_prod_time = [str(x['time_worked']) for x in ts_data if x['product_Name'] == row]
for u in total_prod_time:
(h, m, s) = u.split(':')
pt = datetime.timedelta(hours=int(h), minutes=int(m))
sum_ptime += pt
html += '' + str(row['product_name']) + 'Total Hrs '+str(sum_ptime)[:-3]+''
for dat in ts_data:
if row == dat['product_Name']:
html += ' DeleteEdit'
task_data = db(db.ts_task_data.transaction_id == dat['id']).select(db.ts_task_data.lable_name,db.ts_task_data.value)
for i in task_data:
lable = db(db.ts_form.id == i['lable_name']).select(db.ts_form.lable_name)
if lable:
if '|' in i['value']:
itms =  i['value'].split('|')
html +=  ''+str(lable[0]['lable_name'])+''+str(itms[0])+''
 

Re: [web2py] Re: login after period of inactivity

2020-05-06 Thread Jim S
You said you notice this message after a period of inactivity, but you also 
say this message comes up after clicking login.  What is telling you that 
this is happening after a period of inactivity?

I was hoping to see what you have for default/user/load (which you 
referenced above) - load is not a built-in function in default/user that 
I'm aware of.  

Here is the normal default/user signature:


def user():
"""
exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""

So I was thinking you had put something custom in there.

Are you able to force it to happen by setting your auth.settings.expiration 
to a low number of seconds?

-Jim


On Wednesday, May 6, 2020 at 12:11:55 AM UTC-5, Maurice Waka wrote:
>
> Actually, I want to customize the code to get better feedback, and after 
> digging in I got this discussion 
> 
>
> I just don't know where to exactly place this code, or get something 
> better:
>
> auth.messages.ajax_failed_authentication = DIV(H4(T('Your session has 
> expired')),
> T('Please '),
> A(T('login'),
>   _href=auth.settings.login_url +
> ('?_next=' + 
> urllib.quote(request.env.http_web2py_component_location))
>   if request.env.http_web2py_component_location 
> else ''),
> T(' again to view this content.'),
> _class='not-authorized alert alert-block')
>
>
>
> On Tue, May 5, 2020 at 11:09 PM Jim S > 
> wrote:
>
>> Can you show some code?
>>
>> -Jim
>>
>> On Tuesday, May 5, 2020 at 1:38:29 PM UTC-5, Maurice Waka wrote:
>>>
>>> I notice this message after a period of inactivity. See attached.
>>> The problem is that on clicking on the login link on the app on 
>>> pythonanywhere, I get an error: invalid view (default/user/load).
>>> How can I resolve this?
>>> Regards
>>>
>> -- 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/Px0b1zYX-Zg/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/541b05b3-02b7-4bc8-8773-f093a41bc1ce%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/badaa3f7-1281-412d-81a0-6b053adb8040%40googlegroups.com.