[web2py] Re: cannot disable automatic login after registration

2015-10-25 Thread 'DenesL' via web2py-users

There are more settings to play around with and the book is not always up 
to date with source code changes.
With that in mind I always check the source to see how it works when I am 
having trouble.
The registration process and how it uses those settings is located in 
gluon/tools.py around line 2944 (web2py 2.12.03).
If the way it is coded does not suit you can open an issue in github.

But why create a user account that might need to be deleted?. You seem to 
be trying to handle the situation in a roundabout way.
How about using onvalidation to check all your fields before creating the 
user?.


On Sunday, October 25, 2015 at 6:29:12 AM UTC-4, Pierre wrote:
>
> Yes ok but this is not what I want :
>
>
> extracted from web2py book:
>
> "
>
> If you want to allow people to register and automatically log them in 
> after registration but still want to send an email for verification so that 
> they cannot login again after logout, unless they completed the 
> instructions in the email, you can accomplish it as follows:
>
> auth.settings.registration_requires_verification = True
> auth.settings.login_after_registration = True
>
> "
> here is the problem :
> I added some extra fields to auth_user to provide geolocation data howewer 
> I cannot predict "geolocation user acceptance" so my idea was to simply 
> delete the user account in case geolocation is refused. but this cannot be 
> done since new user is logged in automatically (he cannot log out if his 
> account is deleted). Now I think about a different strategy using 
> permissions and roles like "cannot login till geolocation data provided". 
> This seems like a lot of complexity to solve a simple task ?
>
> Le dimanche 25 octobre 2015 03:55:34 UTC+1, DenesL a écrit :
>>
>>
>> You also need
>>
>> settings.registration_requires_verification = True
>>
>>
>>
>> On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>>>
>>> Hi everyone,
>>>
>>> I tried to do it with no success with this:
>>>
>>> auth.settings.login_after_registration = False
>>>
>>> thanks for your help
>>>
>>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: cannot disable automatic login after registration

2015-10-25 Thread Anthony
First, note that auth.settings.login_after_registration is for 
*automatically* logging in the user immediately after registration. It is 
False by default. However, having it set to False does not prevent the user 
from manually logging in after registration (unless you require 
verification and/or approval, in which case, those requirements must be 
satisfied before login is allowed).

If "geolocation user acceptance" is something that can be handled 
automatically at time of registration, then just use an 
auth.settings.register_onvalidation callback to do the check, and simply 
reject the registration if the check fails. On the other hand, if some 
manual approval process is required, then you should set 
auth.settings.registration_requires_approval 
= True, and that will disable login until the registration has been 
approved by an admin.

Anthony

On Sunday, October 25, 2015 at 6:29:12 AM UTC-4, Pierre wrote:
>
> Yes ok but this is not what I want :
>
>
> extracted from web2py book:
>
> "
>
> If you want to allow people to register and automatically log them in 
> after registration but still want to send an email for verification so that 
> they cannot login again after logout, unless they completed the 
> instructions in the email, you can accomplish it as follows:
>
> auth.settings.registration_requires_verification = True
> auth.settings.login_after_registration = True
>
> "
> here is the problem :
> I added some extra fields to auth_user to provide geolocation data howewer 
> I cannot predict "geolocation user acceptance" so my idea was to simply 
> delete the user account in case geolocation is refused. but this cannot be 
> done since new user is logged in automatically (he cannot log out if his 
> account is deleted). Now I think about a different strategy using 
> permissions and roles like "cannot login till geolocation data provided". 
> This seems like a lot of complexity to solve a simple task ?
>
> Le dimanche 25 octobre 2015 03:55:34 UTC+1, DenesL a écrit :
>>
>>
>> You also need
>>
>> settings.registration_requires_verification = True
>>
>>
>>
>> On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>>>
>>> Hi everyone,
>>>
>>> I tried to do it with no success with this:
>>>
>>> auth.settings.login_after_registration = False
>>>
>>> thanks for your help
>>>
>>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: IS_DATE() and timezones

2015-10-25 Thread Anthony
It appears to be a bug in the IS_DATE validator -- the code expects the 
date object to have a tzinfo attribute, but only datetime and time objects 
have that attribute.

More generally, it is not clear how one should apply transformations to 
dates based on timezones. If you know the date in UTC time, how can you 
tell what the date should be in another timezone without knowing the *time* 
in UTC as well? For example, if you have the date 2015-10-25 in UTC, what 
is the date in the "America/Chicago" timezone? It would be 2015-10-25 if 
the UTC time is after 5:00am, but 2015-10-24 if the UTC time is before 
5:00am. If you want to make such a transformation, you would have to pick a 
particular time of day (either in the local timezone or UTC), such as 
midnight -- but then you should probably be storing datetimes, not simply 
dates.

Anthony

On Sunday, October 25, 2015 at 8:54:40 AM UTC-4, Julian Sanchez wrote:
>
> I'm developing an application that will have users from different time 
> zones.  The intent is to store everything in UTC and translate to user's 
> timezone at display/edit time.  I started working on my own solution when I 
> came across this post 
> which
>  
> seems to indicate that if you specify a timezone parameter to the IS_DATE() 
> validator web2py will do all the timezone translation for you.
>
> However every time I specify the timezone parameter to IS_DATE() I will 
> get no dates validated no matter what
>
> Without specifying a timezone it obviously works:
> def test_date():
> db.define_table('test_table',Field('usr_comment'),Field('comment_date'
> ,requires=IS_DATE('%Y-%m-%d')))
> form =SQLFORM.grid(db.test_table, create=True,editable=True, 
> user_signature=False)
> return dict(form=form)
>
>
> However this:
> def test_date():
> db.define_table('test_table', Field('usr_comment'), Field(
> 'comment_date', requires=IS_DATE('%Y-%m-%d', timezone='America/Chicago')))
> form = SQLFORM.grid(db.test_table, create=True, editable=True, 
> user_signature=False)
> return dict(form=form)
>
> or even this:
> def test_date():
> from pytz import timezone
> mytz = timezone('America/Chicago')
> db.define_table('test_table', Field('usr_comment'),Field(
> 'comment_date',requires=IS_DATE('%Y-%m-%d', timezone=mytz)))
> form=SQLFORM.grid(db.test_table, create=True, editable=True,
> user_signature=False)
> return dict(form=form)
>
> Always tells me "Enter date as 1963-08-28" when submitting the form and 
> never allows me to add/edit values (of course I'm entering dates as 
> 2015-10-25). 
>
> Am I missing something or is there a bug with IS_DATE and timezone 
> handling?
>
> Thanks,
> Julian
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: cannot disable automatic login after registration

2015-10-25 Thread Pierre
Yes ok but this is not what I want :


extracted from web2py book:

"

If you want to allow people to register and automatically log them in after 
registration but still want to send an email for verification so that they 
cannot login again after logout, unless they completed the instructions in 
the email, you can accomplish it as follows:

auth.settings.registration_requires_verification = True
auth.settings.login_after_registration = True

"
here is the problem :
I added some extra fields to auth_user to provide geolocation data howewer 
I cannot predict "geolocation user acceptance" so my idea was to simply 
delete the user account in case geolocation is refused. but this cannot be 
done since new user is logged in automatically (he cannot log out if his 
account is deleted). Now I think about a different strategy using 
permissions and roles like "cannot login till geolocation data provided". 
This seems like a lot of complexity to solve a simple task ?

Le dimanche 25 octobre 2015 03:55:34 UTC+1, DenesL a écrit :
>
>
> You also need
>
> settings.registration_requires_verification = True
>
>
>
> On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>>
>> Hi everyone,
>>
>> I tried to do it with no success with this:
>>
>> auth.settings.login_after_registration = False
>>
>> thanks for your help
>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] IS_DATE() and timezones

2015-10-25 Thread Julian Sanchez
I'm developing an application that will have users from different time 
zones.  The intent is to store everything in UTC and translate to user's 
timezone at display/edit time.  I started working on my own solution when I 
came across this post 
which
 
seems to indicate that if you specify a timezone parameter to the IS_DATE() 
validator web2py will do all the timezone translation for you.

However every time I specify the timezone parameter to IS_DATE() I will get 
no dates validated no matter what

Without specifying a timezone it obviously works:
def test_date():
db.define_table('test_table',Field('usr_comment'),Field('comment_date',
requires=IS_DATE('%Y-%m-%d')))
form =SQLFORM.grid(db.test_table, create=True,editable=True, 
user_signature=False)
return dict(form=form)


However this:
def test_date():
db.define_table('test_table', Field('usr_comment'), Field('comment_date'
, requires=IS_DATE('%Y-%m-%d', timezone='America/Chicago')))
form = SQLFORM.grid(db.test_table, create=True, editable=True, 
user_signature=False)
return dict(form=form)

or even this:
def test_date():
from pytz import timezone
mytz = timezone('America/Chicago')
db.define_table('test_table', Field('usr_comment'),Field('comment_date',
requires=IS_DATE('%Y-%m-%d', timezone=mytz)))
form=SQLFORM.grid(db.test_table, create=True, editable=True,
user_signature=False)
return dict(form=form)

Always tells me "Enter date as 1963-08-28" when submitting the form and 
never allows me to add/edit values (of course I'm entering dates as 
2015-10-25). 

Am I missing something or is there a bug with IS_DATE and timezone handling?

Thanks,
Julian

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: cannot disable automatic login after registration

2015-10-25 Thread 黄祥
hi, pierre,

might i know how do you get the latitude and longitude value for your 
form.vars?

thanks and best regards,
stifan

On Monday, October 26, 2015 at 12:45:01 AM UTC+7, Pierre wrote:
>
> thanks this works : 
>
> auth.settings.register_onvalidation(check_geo)
>
> +
>
> def check_geo(form):
>   if not form.vars.lat or not form.vars.lng:
> redirect(url('registration_failed'))
>
>
> Le dimanche 25 octobre 2015 13:34:36 UTC+1, Anthony a écrit :
>>
>> First, note that auth.settings.login_after_registration is only relevant 
>> when auth.settings.registration_requires_verification = True, as that is 
>> the only case where it makes sense to differentiate whether login should be 
>> allowed immediately or not (when registration does not require 
>> verification, the user can immediately login manually, so no reason not to 
>> do it automatically).
>>
>> Anyway, if "geolocation user acceptance" is something that can be handled 
>> automatically at time of registration, then just use an 
>> auth.settings.register_onvalidation callback to do the check, and simply 
>> reject the registration if the check fails. On the other hand, if some 
>> manual approval process is required, then you should set 
>> auth.settings.registration_requires_approval 
>> = True, and that will disable login until the registration has been 
>> approved by an admin.
>>
>> Anthony
>>
>> On Sunday, October 25, 2015 at 6:29:12 AM UTC-4, Pierre wrote:
>>>
>>> Yes ok but this is not what I want :
>>>
>>>
>>> extracted from web2py book:
>>>
>>> "
>>>
>>> If you want to allow people to register and automatically log them in 
>>> after registration but still want to send an email for verification so that 
>>> they cannot login again after logout, unless they completed the 
>>> instructions in the email, you can accomplish it as follows:
>>>
>>> auth.settings.registration_requires_verification = True
>>> auth.settings.login_after_registration = True
>>>
>>> "
>>> here is the problem :
>>> I added some extra fields to auth_user to provide geolocation data 
>>> howewer I cannot predict "geolocation user acceptance" so my idea was to 
>>> simply delete the user account in case geolocation is refused. but this 
>>> cannot be done since new user is logged in automatically (he cannot log out 
>>> if his account is deleted). Now I think about a different strategy using 
>>> permissions and roles like "cannot login till geolocation data provided". 
>>> This seems like a lot of complexity to solve a simple task ?
>>>
>>> Le dimanche 25 octobre 2015 03:55:34 UTC+1, DenesL a écrit :


 You also need

 settings.registration_requires_verification = True



 On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>
> Hi everyone,
>
> I tried to do it with no success with this:
>
> auth.settings.login_after_registration = False
>
> thanks for your help
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Is it intended that TABLE(rows) makes a table within a table?

2015-10-25 Thread Edward Shave
Seems I overlooked the obvious..!

Thanks DenesL  :0)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Really can't use database reserved words?

2015-10-25 Thread Anthony
You might try using the "rname" feature:

Field('state', rname='st')

or:

Field('state', rname='"state"')

web2py will use "state" as the name, but the database will see the name as 
"st" (or in the second case, the name "state" is passed to the database, 
but it is surrounded by double quotes, so it won't be interpreted as a SQL 
keyword in any SQL statements).

Anthony

On Sunday, October 25, 2015 at 4:48:10 PM UTC-4, pbreit wrote:
>
> I get the whole reserved word conflict thing but am surprised that it 
> can't or isn't worked around? The lists are pretty long and reserve a 
> number of good words like "state" and "group".
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: pass javascript value into sqlform

2015-10-25 Thread 黄祥
thanks for the example, i test it and work, btw, when i try using another 
example is not work (no error occured, but the result is not expected 
(nothing happen) ).
e.g. taken from 
http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation

my code
*controllers/defaut.py*
def test():
btn = BUTTON('Try It', _type = "button", _onclick = """getLocation()""" 
)

scr = SCRIPT("""
var x = document.getElementById("demo");

function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else { 
x.innerHTML = "Geolocation is not supported by this browser.";
}
}

function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude + 
"Longitude: " + position.coords.longitude;  
}
"""
)

return dict(btn = btn, scr = scr)

*views/default/test.html*
{{extend 'layout.html'}}

{{=btn }}

{{=scr }}

{{=DIV(_id='demo')}}

how to achieve it using web2py way?

thanks and best regards,
stifan

On Monday, August 17, 2015 at 7:18:12 AM UTC+7, Val K wrote:
>
> Just for fun - paste in any controller and go to  .../sql_frm_js
>
> def sql_frm_js():
> t_name='any_tbl' # just for more readable because SQLFORM.factory
> f1_name='any_fld_1'
> f2_name='any_fld_2'
> f_id=lambda f, t=t_name: '%s_%s'%(t, f) # return id of html 
> INPUT-element corresponding to field name
> 
> btn1=BUTTON('Click me', _type="button", _onclick ="""$('#%s').val('any 
> value') """%f_id(f1_name) )
> btn2=BUTTON('And me', _type="button", _onclick ="""$('#%s').val( 
> your_JS_fun() ) """%f_id(f1_name) )
>
> scr=SCRIPT("""
> $(document).ready(your_JS_fun_init );
> 
> function your_JS_fun_init()
> {
>  $('#%s').val('Hi, I am your_JS_fun_init');
>  return 
> };
> 
> function your_JS_fun()
> {
>  return 'Hi, I am your_JS_fun';
> };
> """%f_id(f2_name)
> )
>
> frm=SQLFORM.factory(
> Field(f1_name, 'string', comment=DIV(btn1, btn2)), 
> Field(f2_name, 'string'),
> table_name=t_name)
> if frm.process().accepted:
> response.flash=frm.vars[f1_name]+','+frm.vars[f2_name]
> 
> return dict(frm=frm, scr=scr)
>
>
>
>
> On Friday, August 14, 2015 at 3:23:17 AM UTC+3, 黄祥 wrote:
>>
>> hi,
>>
>> is it possible to pass javascript value into sqlform?
>>
>> ref:
>>
>> http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation_error
>>
>> i want to know user location when create or update delivery function, yet 
>> landing in w3schools provide it into javascript value, but don't know how 
>> to put it on web2py sqlform.
>>
>> any idea how to pass javascript value into sqlform?
>>
>> just another idea, i think it's better to have request.geolocation in 
>> web2py core request
>>
>> best regards,
>> stifan
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] string indices must be integers, not str

2015-10-25 Thread Alex Glaros
feel dumb asking about this subject again but what is correct way to get 
the individual value?

here is what the data looks like

{{x=request.get_vars.x}}
this is X: {{=x}}

this is X:
{u'placeName': u'Novato', u'countryCode': u'US', u'lat': 38.061837, 
u'postalcode': u'94949', u'lng': -122.540408, u'adminName2': u'Marin', 
u'adminCode1': u'CA', u'adminCode2': u'041', u'adminName1': u'California'}

When I try to isolate a member of the dict like this:
 {{=x['postalcode']}}

I get this error:

 string indices must be integers, not str


thanks,

Alex Glaros

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: IS_DATE() and timezones

2015-10-25 Thread Anthony
FYI, we're going to remove the timezone option from IS_DATE (which doesn't 
work anyway), so you're better off using a datetime field and setting the 
time to midnight.

Anthony

On Sunday, October 25, 2015 at 12:02:48 PM UTC-4, Julian Sanchez wrote:
>
> Thanks Anthony, great insight.
>
> Most data is user-generated so the intent is to imply midnight at the 
> user's timezone, translate to UTC for storage, then apply the user's 
> timezone when displaying/editing.  Can certainly switch to datetime field 
> and zero out the time.
>
> Cheers,
> Julian
>
> On Sunday, October 25, 2015 at 8:38:12 AM UTC-5, Anthony wrote:
>>
>> It appears to be a bug in the IS_DATE validator -- the code expects the 
>> date object to have a tzinfo attribute, but only datetime and time objects 
>> have that attribute.
>>
>> More generally, it is not clear how one should apply transformations to 
>> dates based on timezones. If you know the date in UTC time, how can you 
>> tell what the date should be in another timezone without knowing the 
>> *time* in UTC as well? For example, if you have the date 2015-10-25 in 
>> UTC, what is the date in the "America/Chicago" timezone? It would be 
>> 2015-10-25 if the UTC time is after 5:00am, but 2015-10-24 if the UTC time 
>> is before 5:00am. If you want to make such a transformation, you would have 
>> to pick a particular time of day (either in the local timezone or UTC), 
>> such as midnight -- but then you should probably be storing datetimes, not 
>> simply dates.
>>
>> Anthony
>>
>> On Sunday, October 25, 2015 at 8:54:40 AM UTC-4, Julian Sanchez wrote:
>>>
>>> I'm developing an application that will have users from different time 
>>> zones.  The intent is to store everything in UTC and translate to user's 
>>> timezone at display/edit time.  I started working on my own solution when I 
>>> came across this post 
>>> which
>>>  
>>> seems to indicate that if you specify a timezone parameter to the IS_DATE() 
>>> validator web2py will do all the timezone translation for you.
>>>
>>> However every time I specify the timezone parameter to IS_DATE() I will 
>>> get no dates validated no matter what
>>>
>>> Without specifying a timezone it obviously works:
>>> def test_date():
>>> db.define_table('test_table',Field('usr_comment'),Field(
>>> 'comment_date',requires=IS_DATE('%Y-%m-%d')))
>>> form =SQLFORM.grid(db.test_table, create=True,editable=True, 
>>> user_signature=False)
>>> return dict(form=form)
>>>
>>>
>>> However this:
>>> def test_date():
>>> db.define_table('test_table', Field('usr_comment'), Field(
>>> 'comment_date', requires=IS_DATE('%Y-%m-%d', timezone='America/Chicago'
>>> )))
>>> form = SQLFORM.grid(db.test_table, create=True, editable=True, 
>>> user_signature=False)
>>> return dict(form=form)
>>>
>>> or even this:
>>> def test_date():
>>> from pytz import timezone
>>> mytz = timezone('America/Chicago')
>>> db.define_table('test_table', Field('usr_comment'),Field(
>>> 'comment_date',requires=IS_DATE('%Y-%m-%d', timezone=mytz)))
>>> form=SQLFORM.grid(db.test_table, create=True, editable=True,
>>> user_signature=False)
>>> return dict(form=form)
>>>
>>> Always tells me "Enter date as 1963-08-28" when submitting the form and 
>>> never allows me to add/edit values (of course I'm entering dates as 
>>> 2015-10-25). 
>>>
>>> Am I missing something or is there a bug with IS_DATE and timezone 
>>> handling?
>>>
>>> Thanks,
>>> Julian
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: cannot disable automatic login after registration

2015-10-25 Thread Pierre
thanks this works : 

auth.settings.register_onvalidation(check_geo)

+

def check_geo(form):
  if not form.vars.lat or not form.vars.lng:
redirect(url('registration_failed'))
   

Le dimanche 25 octobre 2015 13:34:36 UTC+1, Anthony a écrit :
>
> First, note that auth.settings.login_after_registration is only relevant 
> when auth.settings.registration_requires_verification = True, as that is 
> the only case where it makes sense to differentiate whether login should be 
> allowed immediately or not (when registration does not require 
> verification, the user can immediately login manually, so no reason not to 
> do it automatically).
>
> Anyway, if "geolocation user acceptance" is something that can be handled 
> automatically at time of registration, then just use an 
> auth.settings.register_onvalidation callback to do the check, and simply 
> reject the registration if the check fails. On the other hand, if some 
> manual approval process is required, then you should set 
> auth.settings.registration_requires_approval 
> = True, and that will disable login until the registration has been 
> approved by an admin.
>
> Anthony
>
> On Sunday, October 25, 2015 at 6:29:12 AM UTC-4, Pierre wrote:
>>
>> Yes ok but this is not what I want :
>>
>>
>> extracted from web2py book:
>>
>> "
>>
>> If you want to allow people to register and automatically log them in 
>> after registration but still want to send an email for verification so that 
>> they cannot login again after logout, unless they completed the 
>> instructions in the email, you can accomplish it as follows:
>>
>> auth.settings.registration_requires_verification = True
>> auth.settings.login_after_registration = True
>>
>> "
>> here is the problem :
>> I added some extra fields to auth_user to provide geolocation data 
>> howewer I cannot predict "geolocation user acceptance" so my idea was to 
>> simply delete the user account in case geolocation is refused. but this 
>> cannot be done since new user is logged in automatically (he cannot log out 
>> if his account is deleted). Now I think about a different strategy using 
>> permissions and roles like "cannot login till geolocation data provided". 
>> This seems like a lot of complexity to solve a simple task ?
>>
>> Le dimanche 25 octobre 2015 03:55:34 UTC+1, DenesL a écrit :
>>>
>>>
>>> You also need
>>>
>>> settings.registration_requires_verification = True
>>>
>>>
>>>
>>> On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:

 Hi everyone,

 I tried to do it with no success with this:

 auth.settings.login_after_registration = False

 thanks for your help



-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Type Cast Field On The Fly

2015-10-25 Thread Massimo Di Pierro
It is not clear from the post if you want to cast a type at the database 
level or the database level. If you want to do it at the web2py level your 
choice is looping or map

map(lambda row: row.update(field=int(row.field)), rows)

If you want to cast at the database level, tells us the SQL query and we 
can tell you how to translate it in DAL-ese.


On Thursday, 22 October 2015 00:01:04 UTC-5, Benson Myrtil wrote:
>
> Hey guys, 
>
> I have a quick question. Does the DAL support type casting on the fly? I 
> am working with a legacy mssql 2008 database that I cannot alter. Within 
> this database it has a field of integers but the field type is string. When 
> I try to run the sum() function on that field I get  'gluon.contrib.pypyodbc.ProgrammingError'>((u'42000', u'[42000] 
> [FreeTDS][SQL Server]Operand data type char is invalid for sum operator.'))
>
> Short of having to loop over the fields and int() them so I can add them, 
> I was wondering if there was anyway to do this within web2py/DAL framework?
>
> I tried to change the field type before running the sum() function hoping 
> I could trick it but that still did not work.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Resource webservice built on web2py for web2py comunity [BETA]

2015-10-25 Thread Ivica Kralj
Hi,

The site is maintained but not actively as I would like.

I've just added new example for the contact form. 
http://www.web2pyref.com/example/contact-form-contact-form-with-recaptcha-and-gmail-smtp-service-app-1

My intention is to still continue adding new references and new examples 
but unfortunately I have other priorities going on at the moment.

On Friday, 23 October 2015 15:58:59 UTC+2, Ron Chatterjee wrote:
>
> Wondering if we can have more examples, source code and snippets gets put 
> into web2pyref. I don't know who is maintaining the page but few things I 
> wish I could use example of sending email using gmail SMTP and contact 
> form, voting, likes, paypal ecommerce, rating, bootstrap3 and social media 
> integration etc. Just some thoughts...
>
>
>
> On Monday, June 8, 2015 at 8:19:32 PM UTC-4, Carlos A. Armenta Castro 
> wrote:
>>
>> I don't know if web2pyslices is better than web2pyref and it doesn't care 
>> for me. My personal opinion is: We need a decent, powerful and usable 
>> website to collect all ours code snippets, examples, recipes, plugins, demo 
>> sites, templates (bs2, bs3, etc.) and for to be honest that is our 
>> Achilles' heel. We have a really great community, but a no optimal system 
>> to show our work to the world (and to motivate the newbies). 
>>
>> Finally, I appreciate the work of the web2pyref.com and web2pyslices.com, 
>> and I think we need to be part of that kind of projects contributing to the 
>> source code, promotion and with donations.
>>
>> Sorry for my bad english.
>>
>> El lunes, 8 de junio de 2015, 6:16:43 (UTC-7), Carlos Cesar Caballero 
>> Díaz escribió:
>>>
>>> Some months ago, because I can´t post anything to web2pyslices (others 
>>> have the same problem and no one knows why) I post that I could motivate 
>>> some of my team (including a designer) for building (and maintain) a new 
>>> web2pyslices, and the proposal remains on the table. Right now I have two 
>>> ideas, first, open source the site, and motivate the comunity to 
>>> contribute, the other thing is, taking advantage of the web2pyslices 
>>> maintenance problems, mix everything in a improved new web2py site, and 
>>> web2pyslices could continue alive, for consulting, in some kind of read 
>>> only mode.
>>>
>>>
>>> El 07/06/15 a las 20:49, Massimo Di Pierro escribió:
>>>
>>> The maintainers of web2pyslices do not want to do it any more. The 
>>> domain has been donated to me (although we are in the process of 
>>> transferring it) so if Ivica want to put the effort of maintaining an 
>>> alternate site, that is better for me than maintaining web2pyslices, as 
>>> long as info is not lost. 
>>>
>>>
>>> On Saturday, 6 June 2015 04:52:56 UTC-5, Ivica Kralj wrote: 

 That is fine Niphlod. I created this project, primary for personal 
 reason to have quick resource to examples when I 'm working on my small 
 projects,. I think people, specially newbies, might find it useful. 
 Comparing myself to allot of members here, I do consider myself a newbie, 
 although I have joined this group over 4-5 years ago or so. 

 Any feature can be added if its needed or requested. 

 I agree, over the years there were number of resources,  most of them 
 got abandoned, but their resources are still out here (alter ego for 
 example), and I still regularly visit them. Even if they might not work 
 with current web2py version, we can still learn from them, well I do.


 On Friday, 5 June 2015 21:35:08 UTC+2, Niphlod wrote: 
>
> not to be the buzzkiller but I won't post any example there that 
> exists on web2pyslices.com that ATM has at least 2 killer features: 
> social login and packages uploads.  
>
> BTW: until all snippets are continously tested, this is going to 
> become the 4th incarnation of a "web2py snippet blog/container/etc" with 
> outdated pieces of code within the next year, when the buzz wears off.
>
 -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: IS_DATE() and timezones

2015-10-25 Thread Julian Sanchez
Thanks Anthony, great insight.

Most data is user-generated so the intent is to imply midnight at the 
user's timezone, translate to UTC for storage, then apply the user's 
timezone when displaying/editing.  Can certainly switch to datetime field 
and zero out the time.

Cheers,
Julian

On Sunday, October 25, 2015 at 8:38:12 AM UTC-5, Anthony wrote:
>
> It appears to be a bug in the IS_DATE validator -- the code expects the 
> date object to have a tzinfo attribute, but only datetime and time objects 
> have that attribute.
>
> More generally, it is not clear how one should apply transformations to 
> dates based on timezones. If you know the date in UTC time, how can you 
> tell what the date should be in another timezone without knowing the 
> *time* in UTC as well? For example, if you have the date 2015-10-25 in 
> UTC, what is the date in the "America/Chicago" timezone? It would be 
> 2015-10-25 if the UTC time is after 5:00am, but 2015-10-24 if the UTC time 
> is before 5:00am. If you want to make such a transformation, you would have 
> to pick a particular time of day (either in the local timezone or UTC), 
> such as midnight -- but then you should probably be storing datetimes, not 
> simply dates.
>
> Anthony
>
> On Sunday, October 25, 2015 at 8:54:40 AM UTC-4, Julian Sanchez wrote:
>>
>> I'm developing an application that will have users from different time 
>> zones.  The intent is to store everything in UTC and translate to user's 
>> timezone at display/edit time.  I started working on my own solution when I 
>> came across this post 
>> which
>>  
>> seems to indicate that if you specify a timezone parameter to the IS_DATE() 
>> validator web2py will do all the timezone translation for you.
>>
>> However every time I specify the timezone parameter to IS_DATE() I will 
>> get no dates validated no matter what
>>
>> Without specifying a timezone it obviously works:
>> def test_date():
>> db.define_table('test_table',Field('usr_comment'),Field(
>> 'comment_date',requires=IS_DATE('%Y-%m-%d')))
>> form =SQLFORM.grid(db.test_table, create=True,editable=True, 
>> user_signature=False)
>> return dict(form=form)
>>
>>
>> However this:
>> def test_date():
>> db.define_table('test_table', Field('usr_comment'), Field(
>> 'comment_date', requires=IS_DATE('%Y-%m-%d', timezone='America/Chicago'
>> )))
>> form = SQLFORM.grid(db.test_table, create=True, editable=True, 
>> user_signature=False)
>> return dict(form=form)
>>
>> or even this:
>> def test_date():
>> from pytz import timezone
>> mytz = timezone('America/Chicago')
>> db.define_table('test_table', Field('usr_comment'),Field(
>> 'comment_date',requires=IS_DATE('%Y-%m-%d', timezone=mytz)))
>> form=SQLFORM.grid(db.test_table, create=True, editable=True,
>> user_signature=False)
>> return dict(form=form)
>>
>> Always tells me "Enter date as 1963-08-28" when submitting the form and 
>> never allows me to add/edit values (of course I'm entering dates as 
>> 2015-10-25). 
>>
>> Am I missing something or is there a bug with IS_DATE and timezone 
>> handling?
>>
>> Thanks,
>> Julian
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Table migration problem on GAE Cloud SQL (locally)

2015-10-25 Thread Massimo Di Pierro
Somehow they got corrupted. To repair: 1) make sure the define_table 
structure matches the tables as defined in the the database; 2) set 
fake_migrate=True. Once it works remove fake_migrate=True and add 
enable_migrate=False (do not touch them any more).

On Thursday, 22 October 2015 11:44:50 UTC-5, Sébastien wrote:
>
> Might this be a bug on GAE? Could someone confirm that on GAE migration is 
> fine?
>
> On Saturday, 17 October 2015 13:13:21 UTC+2, Sébastien wrote:
>>
>> Hello,
>>
>> I am working locally on GAE (with Cloud SQL) and I can't seem to be able 
>> to add a new field to a table. I keep having  'xxx.table appears corrupted' 
>> messages.
>>
>> This is what I do before getting the error.
>>
>>
>> 1. To begin with I have:
>>
>> DAL('google:sql:xxx:xxx/xxx’, migrate_enabled = False, migrate=False)
>> db.define_table('test', Field('name'))
>>
>> ---> everything all right
>>
>> 2. Then I change DAL connexion:
>> DAL('google:sql:xxx:xxx/xxx’, migrate_enabled = True, migrate=False)
>>
>> 3, And update define_table with a new field + a migrate name
>> db.define_table('test', Field('name'), Field('another'), 
>> migrate='test.table')
>>
>> ---> I get the following error:
>>
>> […]/gluon/packages/dal/pydal/adapters/base.py:1370: Warning: Can't create 
>> database 'silentdrop'; database exists
>>   ret = self.cursor.execute(command, *a[1:], **b)
>> […]/gluon/packages/dal/pydal/adapters/base.py:1370: Warning: Table 
>> 'web2py_filesystem' already exists
>>   ret = self.cursor.execute(command, *a[1:], **b)
>> ERROR2015-10-17 11:06:35,531 restricted.py:174] Traceback (most 
>> recent call last):
>>   File "[…]/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "[…]/applications/xxx/models/xxx.py”, line 35, in 
>> migrate= ‘test.table')
>>   File "[…]/gluon/packages/dal/pydal/base.py", line 834, in define_table
>> table = self.lazy_define_table(tablename,*fields,**args)
>>   File "[…]/gluon/packages/dal/pydal/base.py", line 873, in 
>> lazy_define_table
>> polymodel=polymodel)
>>   File "[…]/gluon/packages/dal/pydal/adapters/base.py", line 494, in 
>> create_table
>> raise RuntimeError('File %s appears corrupted' % table._dbt)
>> RuntimeError: File $HOME/socialTV/databases/test.table appears corrupted
>>
>>
>> I would really appreciate if someone could help me with this as I can't 
>> seem to find a solution.
>> Thank you!
>>
>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Fwd: aiosmtpd 1.0a1 - asyncio-based implementations of SMTP/LMTP

2015-10-25 Thread Massimo Di Pierro
Docs say: This is a server for SMTP and related protocols, similar in 
utility to the standard library’s smtpd.py module, but rewritten to be 
based on asyncio for Python 3.

On Thursday, 22 October 2015 07:36:46 UTC-5, mcm wrote:
>
> Works on python2.7? or only 3.5?
>
> 2015-10-20 16:06 GMT+02:00 Massimo DiPierro :
>
>> This is nice if you want a pure python SMTP server
>>
>> Begin forwarded message:
>>
>> *From: *Barry Warsaw 
>> *Subject: **aiosmtpd 1.0a1 - asyncio-based implementations of SMTP/LMTP*
>> *Date: *October 20, 2015 at 8:51:29 AM CDT
>> *To: *
>> *Reply-To: *python-l...@python.org
>>
>> I'm very happy to announce the first alpha release of aiosmtpd, an
>> asyncio-based implementation of SMTP and LMTP.
>>
>> http://aiosmtpd.readthedocs.org/en/latest/
>> https://pypi.python.org/pypi/aiosmtpd/1.0a1
>>
>> This library can be used as a standalone server, or as a testing 
>> framework for
>> applications that send email.  It's inspired by several previous packages
>> including the stdlib smtpd.py, lazr.smtptest, Benjamin Bader's aiosmtp, 
>> and
>> submodules in GNU Mailman.
>>
>> This is an alpha release, so it can obviously use lots of feedback, and
>> contributions are very much welcome.  We're developing the library on 
>> GitLab;
>> see the RTD link above for details.
>>
>> Brought to you by the aiosmtpd hacking cabal of Andrew Kuchling, Eric 
>> Smith,
>> Jason Coombs, R. David Murray and myself.
>>
>> Our aim is to include aiosmtpd in the Python 3.6 stdlib as a better
>> alternative to smtpd.py.
>>
>> Cheers,
>> -Barry
>> -- 
>> https://mail.python.org/mailman/listinfo/python-announce-list
>>
>>Support the Python Software Foundation:
>>http://www.python.org/psf/donations/
>>
>>
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.