[web2py] Re: change the record of a table

2018-04-25 Thread Anthony

>
> I get this error 
> Not Authorized
> Insufficient privileges 
>

That's not related to any of the code you have shown. Are you using Auth? 

-- 
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: change the record of a table

2018-04-24 Thread Vash


On Tuesday, April 24, 2018 at 11:46:07 AM UTC-7, Anthony wrote:
>
> On Tuesday, April 24, 2018 at 2:37:37 PM UTC-4, Vash wrote:
>>
>> say I have a table
>> db.define_table('mytable',
>>Field('is_public', 'boolean', default=False),
>> )
>> I want to toggle this to true if user clicked on the icon
>> if request.args(0) is not None:
>> q = ((db.checklists.user_email == auth.user.email) & (db.checklists.id 
>> == request.args(0)))
>> row=db(q).select().first()
>> row.update_record(is_public=not is_public)
>> would this work?
>>
>
> You've got the code, so can't you test it? Does it not do what you are 
> expecting? Without more context, it's hard to say, though from what you 
> have shown, the "is_public" variable is not defined. Perhaps you meant to 
> use row.is_public. Alternatively, you could do is_public=not 
> db.checklists.is_public, which will reverse whatever the current value is.
>
> Anthony
>  
>


I get this error 
Not Authorized
Insufficient privileges 

-- 
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: change the record of a table

2018-04-24 Thread Anthony
On Tuesday, April 24, 2018 at 2:37:37 PM UTC-4, Vash wrote:
>
> say I have a table
> db.define_table('mytable',
>Field('is_public', 'boolean', default=False),
> )
> I want to toggle this to true if user clicked on the icon
> if request.args(0) is not None:
> q = ((db.checklists.user_email == auth.user.email) & (db.checklists.id == 
> request.args(0)))
> row=db(q).select().first()
> row.update_record(is_public=not is_public)
> would this work?
>

You've got the code, so can't you test it? Does it not do what you are 
expecting? Without more context, it's hard to say, though from what you 
have shown, the "is_public" variable is not defined. Perhaps you meant to 
use row.is_public. Alternatively, you could do is_public=not 
db.checklists.is_public, which will reverse whatever the current value is.

Anthony
 

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