Re: [web2py] Re: Appconfig cast boolean

2015-11-19 Thread Mark Graves
It appears that auth.settings.create_user_groups takes either False or the
string that formats the user group creation message.

So you'll need to provide a string format representation ie '%(id)s' as is
shown in the error.

However that won't convert to a boolean, so your cast function will fail.

-Mark

On Thu, Nov 19, 2015 at 11:22 PM, 黄祥  wrote:

> same result, here is step i took
> 1. create new simple application from web2py admin named a
> 2. add auth in privates/appconfig.ini
> [auth]
> create_user_groups = 1
> 3. add auth in models/db.py
> auth.settings.create_user_groups = myconf.take('auth.create_user_groups',
> cast = lambda value: bool(int(value) ) )
>
> attached the simple app that i took the step above, when i change
> create_user_groups = 0, no error occured when i sign up, but, when i set
> create_user_group = 1, same error traceback occured, when i sign up
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/rohbrJEZG_E/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


Re: [web2py] Re: Appconfig cast boolean

2015-11-19 Thread Mark Graves
Also:

auth.settings.create_user_groups = myconf.take('auth.create_user_groups',
cast=lambda value: bool(int(value)))



On Thu, Nov 19, 2015 at 10:53 PM, Mark Graves  wrote:

> Can you reproduce this error in a fresh welcome app?
>
> Then you can send just the one line?
>
> Is it solely:
>
> ; auth
> [auth]
> create_user_groups = 1
>
> VS
>
> ; auth
> [auth]
> create_user_groups = 0
>
> ?
>
>
>
> On Thu, Nov 19, 2015 at 10:44 PM, 黄祥  wrote:
>
>> pardon, i just tried, what is discussed in this thread on my
>> configuration, parsing as string .'auth.create_user_groups' not
>> auth.create_user_groups as a variable
>> e.g.
>> models/db.py
>> auth.settings.create_user_groups = False
>>
>> i want to change the configuration into privates/appconfig.ini with :
>> e.g.
>> privates/appconfig.ini
>> [auth]
>> create_user_groups = 0 ; return an error traceback when value = 1, when
>> value = 0, no error occured, works as expected
>>
>> models/db.py
>> auth.settings.create_user_groups = myconf.take('auth.create_user_groups',
>> cast = lambda value: bool(int(value) ) )
>>
>> but it returns an error when i set the value in privates/appconfig.ini
>> into 1
>>
>> any idea?
>>
>> thanks n best regards,
>> stifan
>>
>>
>> On Friday, November 20, 2015 at 11:36:33 AM UTC+7, Mark Graves wrote:
>>>
>>> I just tried to reproduce your error and could not.
>>>
>>> Judging from the error, are you sure you are passing in the string
>>> 'auth.create_user_groups' and not auth.create_user_groups as a variable?
>>>
>>>
>>>
>>> On Thu, Nov 19, 2015 at 9:32 PM, 黄祥  wrote:
>>>
 tested it. return an error if i put the value int = 1 as true in
 appconfig.ini
 e.g.
 privates/appconfig.ini
 [auth]
 create_user_groups = 0 ; return an error traceback when value = 1, when
 value = 0, no error occured, works as expected

 models/db.py
 auth.settings.create_user_groups =
 myconf.take('auth.create_user_groups', cast = lambda value: bool(int(value)
 ) )

 error traceback:
 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.

 Traceback (most recent call last):
   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
 restricted
 exec ccode in environment
   File 
 "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py"
  
 ,
  line 44, in 
   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 412, in 
 
 self._caller = lambda f: f()
   File 
 "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py"
  
 ,
  line 19, in user
 return dict(form=auth())
   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 1614, in 
 __call__
 return getattr(self, args[0])()
   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 2939, in 
 register
 self.settings.create_user_groups % form.vars, description)
 TypeError: unsupported operand type(s) for %: 'bool' and 'Storage'

 Error snapshot [image: help]
 

 (unsupported operand type(s) for %: 'bool'
 and 'Storage')

 --
 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/rohbrJEZG_E/unsubscribe.
 To unsubscribe from this group and all its topics, 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/rohbrJEZG_E/unsubscribe.
>> To unsubscribe from this group and all its topics, 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 th

Re: [web2py] Re: Appconfig cast boolean

2015-11-19 Thread Mark Graves
Can you reproduce this error in a fresh welcome app?

Then you can send just the one line?

Is it solely:

; auth
[auth]
create_user_groups = 1

VS

; auth
[auth]
create_user_groups = 0

?



On Thu, Nov 19, 2015 at 10:44 PM, 黄祥  wrote:

> pardon, i just tried, what is discussed in this thread on my
> configuration, parsing as string .'auth.create_user_groups' not
> auth.create_user_groups as a variable
> e.g.
> models/db.py
> auth.settings.create_user_groups = False
>
> i want to change the configuration into privates/appconfig.ini with :
> e.g.
> privates/appconfig.ini
> [auth]
> create_user_groups = 0 ; return an error traceback when value = 1, when
> value = 0, no error occured, works as expected
>
> models/db.py
> auth.settings.create_user_groups = myconf.take('auth.create_user_groups',
> cast = lambda value: bool(int(value) ) )
>
> but it returns an error when i set the value in privates/appconfig.ini
> into 1
>
> any idea?
>
> thanks n best regards,
> stifan
>
>
> On Friday, November 20, 2015 at 11:36:33 AM UTC+7, Mark Graves wrote:
>>
>> I just tried to reproduce your error and could not.
>>
>> Judging from the error, are you sure you are passing in the string
>> 'auth.create_user_groups' and not auth.create_user_groups as a variable?
>>
>>
>>
>> On Thu, Nov 19, 2015 at 9:32 PM, 黄祥  wrote:
>>
>>> tested it. return an error if i put the value int = 1 as true in
>>> appconfig.ini
>>> e.g.
>>> privates/appconfig.ini
>>> [auth]
>>> create_user_groups = 0 ; return an error traceback when value = 1, when
>>> value = 0, no error occured, works as expected
>>>
>>> models/db.py
>>> auth.settings.create_user_groups =
>>> myconf.take('auth.create_user_groups', cast = lambda value: bool(int(value)
>>> ) )
>>>
>>> error traceback:
>>> Traceback
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>>
>>> Traceback (most recent call last):
>>>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
>>> restricted
>>> exec ccode in environment
>>>   File 
>>> "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
>>> , 
>>> line 44, in 
>>>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 412, in 
>>> 
>>> self._caller = lambda f: f()
>>>   File 
>>> "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
>>> , 
>>> line 19, in user
>>> return dict(form=auth())
>>>   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 1614, in 
>>> __call__
>>> return getattr(self, args[0])()
>>>   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 2939, in 
>>> register
>>> self.settings.create_user_groups % form.vars, description)
>>> TypeError: unsupported operand type(s) for %: 'bool' and 'Storage'
>>>
>>> Error snapshot [image: help]
>>> 
>>>
>>> (unsupported operand type(s) for %: 'bool'
>>> and 'Storage')
>>>
>>> --
>>> 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/rohbrJEZG_E/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/rohbrJEZG_E/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


Re: [web2py] Re: Appconfig cast boolean

2015-11-19 Thread 黄祥
pardon, i just tried, what is discussed in this thread on my configuration, 
parsing as string .'auth.create_user_groups' not auth.create_user_groups as 
a variable
e.g.
models/db.py
auth.settings.create_user_groups = False

i want to change the configuration into privates/appconfig.ini with :
e.g.
privates/appconfig.ini
[auth]
create_user_groups = 0 ; return an error traceback when value = 1, when 
value = 0, no error occured, works as expected

models/db.py
auth.settings.create_user_groups = myconf.take('auth.create_user_groups', 
cast = lambda value: bool(int(value) ) )

but it returns an error when i set the value in privates/appconfig.ini into 
1

any idea?

thanks n best regards,
stifan


On Friday, November 20, 2015 at 11:36:33 AM UTC+7, Mark Graves wrote:
>
> I just tried to reproduce your error and could not.
>
> Judging from the error, are you sure you are passing in the string 
> 'auth.create_user_groups' and not auth.create_user_groups as a variable?
>
>
>
> On Thu, Nov 19, 2015 at 9:32 PM, 黄祥 > 
> wrote:
>
>> tested it. return an error if i put the value int = 1 as true in 
>> appconfig.ini
>> e.g.
>> privates/appconfig.ini
>> [auth]
>> create_user_groups = 0 ; return an error traceback when value = 1, when 
>> value = 0, no error occured, works as expected
>>
>> models/db.py
>> auth.settings.create_user_groups = myconf.take('auth.create_user_groups', 
>> cast = lambda value: bool(int(value) ) )
>>
>> error traceback:
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>>
>> Traceback (most recent call last):
>>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
>> , 
>> line 44, in 
>>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 412, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
>> , 
>> line 19, in user
>> return dict(form=auth())
>>   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 1614, in __call__
>> return getattr(self, args[0])()
>>   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 2939, in register
>> self.settings.create_user_groups % form.vars, description)
>> TypeError: unsupported operand type(s) for %: 'bool' and 'Storage'
>>
>> Error snapshot [image: help] 
>> 
>>
>> (unsupported operand type(s) for %: 'bool' 
>> and 'Storage')
>>
>> -- 
>> 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/rohbrJEZG_E/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.


Re: [web2py] Re: Appconfig cast boolean

2015-11-19 Thread Mark Graves
I just tried to reproduce your error and could not.

Judging from the error, are you sure you are passing in the string
'auth.create_user_groups' and not auth.create_user_groups as a variable?



On Thu, Nov 19, 2015 at 9:32 PM, 黄祥  wrote:

> tested it. return an error if i put the value int = 1 as true in
> appconfig.ini
> e.g.
> privates/appconfig.ini
> [auth]
> create_user_groups = 0 ; return an error traceback when value = 1, when
> value = 0, no error occured, works as expected
>
> models/db.py
> auth.settings.create_user_groups = myconf.take('auth.create_user_groups',
> cast = lambda value: bool(int(value) ) )
>
> error traceback:
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
> , 
> line 44, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 412, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
> , 
> line 19, in user
> return dict(form=auth())
>   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 1614, in __call__
> return getattr(self, args[0])()
>   File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 2939, in register
> self.settings.create_user_groups % form.vars, description)
> TypeError: unsupported operand type(s) for %: 'bool' and 'Storage'
>
> Error snapshot [image: help]
> 
>
> (unsupported operand type(s) for %: 'bool'
> and 'Storage')
>
> --
> 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/rohbrJEZG_E/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


Re: [web2py] Re: Appconfig cast boolean

2015-11-19 Thread 黄祥
tested it. return an error if i put the value int = 1 as true in 
appconfig.ini
e.g.
privates/appconfig.ini
[auth]
create_user_groups = 0 ; return an error traceback when value = 1, when 
value = 0, no error occured, works as expected

models/db.py
auth.settings.create_user_groups = myconf.take('auth.create_user_groups', 
cast = lambda value: bool(int(value) ) )

error traceback:
Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Traceback (most recent call last):
  File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
, 
line 44, in 
  File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 412, in 
self._caller = lambda f: f()
  File 
"/Users/MacBookPro/site/web2py/applications/testing/controllers/default.py" 
, 
line 19, in user
return dict(form=auth())
  File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 1614, in __call__
return getattr(self, args[0])()
  File "/Users/MacBookPro/site/web2py/gluon/tools.py", line 2939, in register
self.settings.create_user_groups % form.vars, description)
TypeError: unsupported operand type(s) for %: 'bool' and 'Storage'

Error snapshot [image: help] 


(unsupported operand type(s) for %: 'bool' and 
'Storage')

-- 
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: Appconfig cast boolean

2015-08-13 Thread Mark Graves
Set migrate = 

(Empty string) => False

> On Aug 13, 2015, at 8:58 AM, ermolaev.icrea...@gmail.com wrote:
> 
> I talk about it!
> 
> If in .ini file:
> 
> migrate = False
> 
> it conderted to string too and is True in python code!
> 
> понедельник, 3 августа 2015 г., 3:51:52 UTC+3 пользователь Mark Graves 
> написал:
>> 
>> What is the proper syntax for appconfig.ini if the cast is a boolean.
>> 
>> With a fresh install of web2py source, 
>> 
>> appconfig.ini contents:
>> 
>> 
>> ; App configuration 
>> 
>> ; db configuration 
>> 
>> [db] 
>> 
>> uri   = sqlite://storage.sqlite 
>> migrate   = 0 
>> pool_size = 1 
>>  
>> ; smtp address and credentials 
>> [smtp] 
>> server = smtp.gmail.com:587 
>> sender = y...@gmail.com 
>> login  = username:password 
>> 
>> ; form styling 
>> [forms] 
>> formstyle = bootstrap3_inline 
>> separator =
>> 
>> 
>> 
>> 
>> default/index
>> 
>> 
>> 
>> myconf = AppConfig(reload=True)
>> 
>> mc = myconf.take('db.migrate',cast=bool)
>> 
>> print mc
>> print type(mc)
>> 
>> 
>> 
>> output:
>> 
>> 
>> 
>> True
>> 
>> 
>> switching to False yields same output.
>> 
>> What am i doing wrong?
> 
> -- 
> 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/rohbrJEZG_E/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


[web2py] Re: Appconfig cast boolean

2015-08-13 Thread ermolaev . icreator
I talk about it!

If in .ini file:

migrate = False

it conderted to string too and is True in python code!

понедельник, 3 августа 2015 г., 3:51:52 UTC+3 пользователь Mark Graves 
написал:
>
> What is the proper syntax for appconfig.ini if the cast is a boolean.
>
> With a fresh install of web2py source, 
>
> appconfig.ini contents:
>
>
> ; App configuration 
>
> ; db configuration 
>
> [db] 
>
> uri   = sqlite://storage.sqlite 
> migrate   = 0 
> pool_size = 1 
>  
> ; smtp address and credentials 
> [smtp] 
> server = smtp.gmail.com:587 
> sender = y...@gmail.com 
> login  = username:password 
>
> ; form styling 
> [forms] 
> formstyle = bootstrap3_inline 
> separator =
>
>
>
> default/index
>
>
> myconf = AppConfig(reload=True)
>
> mc = myconf.take('db.migrate',cast=bool)
>
> print mc
> print type(mc)
>
>
>
> output:
>
>
> True
> 
>
> switching to False yields same output.
>
> What am i doing wrong?
>
>

-- 
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: Appconfig cast boolean

2015-08-10 Thread Massimo Di Pierro
That that should be correct.

On Sunday, 9 August 2015 11:26:36 UTC-5, Mark Graves wrote:
>
> And, sanity check here, I can also do the following, correct:
>
> [db] 
>
> uri   = sqlite://storage.sqlite 
> migrate   = 
>
> myconf = AppConfig()
>
> mc = myconf.take('db.migrate',cast=bool)
>
> print mc
> print type(mc)
>
> Which should yield False, Boolean
>
>
>
>
> On Monday, August 3, 2015 at 9:09:37 AM UTC-5, Mark Graves wrote:
>>
>> Should've thought of that.
>>
>> Nice to confirm intended behavior.
>>
>> I guess I could have done bool(mc) = myconf.take('db.migrate',cast = int)
>>
>> On Monday, August 3, 2015 at 6:22:09 AM UTC-5, Anthony wrote:
>>>
>>> Therefore:
>>>
>>> mc = myconf.take('db.migrate',cast=lambda value: bool(int(value)))
>>>
>>> Anthony
>>>
>>> On Monday, August 3, 2015 at 7:08:00 AM UTC-4, Leonel Câmara wrote:

 Well you're casting a string so any non-empty string is True. You have 
 to cast to an int.

>>>

-- 
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: Appconfig cast boolean

2015-08-09 Thread Mark Graves
And, sanity check here, I can also do the following, correct:

[db] 

uri   = sqlite://storage.sqlite 
migrate   = 

myconf = AppConfig()

mc = myconf.take('db.migrate',cast=bool)

print mc
print type(mc)

Which should yield False, Boolean




On Monday, August 3, 2015 at 9:09:37 AM UTC-5, Mark Graves wrote:
>
> Should've thought of that.
>
> Nice to confirm intended behavior.
>
> I guess I could have done bool(mc) = myconf.take('db.migrate',cast = int)
>
> On Monday, August 3, 2015 at 6:22:09 AM UTC-5, Anthony wrote:
>>
>> Therefore:
>>
>> mc = myconf.take('db.migrate',cast=lambda value: bool(int(value)))
>>
>> Anthony
>>
>> On Monday, August 3, 2015 at 7:08:00 AM UTC-4, Leonel Câmara wrote:
>>>
>>> Well you're casting a string so any non-empty string is True. You have 
>>> to cast to an int.
>>>
>>

-- 
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: Appconfig cast boolean

2015-08-03 Thread 黄祥
nice, it seems we lack of it in the scaffolding app. (in private.ini there 
is a migrate value yet in the db.py not have)

best regards,
stifan

On Monday, August 3, 2015 at 6:22:09 PM UTC+7, Anthony wrote:
>
> Therefore:
>
> mc = myconf.take('db.migrate',cast=lambda value: bool(int(value)))
>
> Anthony
>
> On Monday, August 3, 2015 at 7:08:00 AM UTC-4, Leonel Câmara wrote:
>>
>> Well you're casting a string so any non-empty string is True. You have to 
>> cast to an int.
>>
>

-- 
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: Appconfig cast boolean

2015-08-03 Thread Mark Graves
Should've thought of that.

Nice to confirm intended behavior.

I guess I could have done bool(mc) = myconf.take('db.migrate',cast = int)

On Monday, August 3, 2015 at 6:22:09 AM UTC-5, Anthony wrote:
>
> Therefore:
>
> mc = myconf.take('db.migrate',cast=lambda value: bool(int(value)))
>
> Anthony
>
> On Monday, August 3, 2015 at 7:08:00 AM UTC-4, Leonel Câmara wrote:
>>
>> Well you're casting a string so any non-empty string is True. You have to 
>> cast to an int.
>>
>

-- 
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: Appconfig cast boolean

2015-08-03 Thread Anthony
Therefore:

mc = myconf.take('db.migrate',cast=lambda value: bool(int(value)))

Anthony

On Monday, August 3, 2015 at 7:08:00 AM UTC-4, Leonel Câmara wrote:
>
> Well you're casting a string so any non-empty string is True. You have to 
> cast to an int.
>

-- 
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: Appconfig cast boolean

2015-08-03 Thread Leonel Câmara
Well you're casting a string so any non-empty string is True. You have to 
cast to an int.

-- 
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.