[web2py] auth_user extra fields + row.to_dict()

2016-04-05 Thread Mark Graves
Hey everyone, I saw a random bug in an app I'm working on, and I was wondering what the correct approach is. I have auth.settings.extra_fields["auth_user"] = [LIST_OF_FIELDS] later, I select that row and get it as a dict: row = db(db.auth_user.id == user_id).select().first().as_dict() then I

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Richard Vézina
Hello Mark, Not sure about the bool part, I think web2py treat bool like that to comply with all the different backend and the apdater does the rest... On the other hand I am curious that you update row with simple update(), you suppose to use update_record() Ref: http://www.web2py.com/books/def

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Anthony
> > On the other hand I am curious that you update row with simple update(), > you suppose to use update_record() > They are both valid methods -- .update updates the Row object itself (like updating a dictionary), whereas .update_record updates the record in the database. You can actually iss

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Anthony
On Wednesday, April 6, 2016 at 11:20:44 AM UTC-4, Anthony wrote: > > On the other hand I am curious that you update row with simple update(), >> you suppose to use update_record() >> > > They are both valid methods -- .update updates the Row object itself (like > updating a dictionary), whereas .

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Richard Vézina
You maybe right Anthony abour update_record() it really depend though of what he is trying todo... :) Richard On Wed, Apr 6, 2016 at 11:21 AM, Anthony wrote: > On Wednesday, April 6, 2016 at 11:20:44 AM UTC-4, Anthony wrote: >> >> On the other hand I am curious that you update row with simple

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Anthony
On Wednesday, April 6, 2016 at 11:30:34 AM UTC-4, Richard wrote: > > You maybe right Anthony abour update_record() it really depend though of > what he is trying todo... > Well at the point where row.update() is called, row is already a dictionary, so there is no .update_record() at that point.

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Richard Vézina
Yeah you right... On Wed, Apr 6, 2016 at 12:06 PM, Anthony wrote: > On Wednesday, April 6, 2016 at 11:30:34 AM UTC-4, Richard wrote: >> >> You maybe right Anthony abour update_record() it really depend though of >> what he is trying todo... >> > > Well at the point where row.update() is called,

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Mark Graves
Hey Anthony and Richard, Yes you are both correct. I am attempting to create a usable JSON object. The confounding details from what I can tell are: 1.) the offending method is defined in a model file, which returns a dictionary, which is then json serialized via response.json(RETURNED_FROM_MO

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Mark Graves
Offending code from a fresh web2py welcome app: in db.py before auth.define_tables() from gluon.contrib.populate import populate auth.settings.extra_fields['auth_user'] = [Field('test_field_1','boolean')] in controller default.py def test(): if db(db.auth_user.id>0).isempty(): po

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Anthony
> > table = db.auth_user > fields = ['id','first_name'] > fields.append('test_field_1') > > query = table.id > 0 > > row = db(query).select(*fields).first().as_dict() > The problem is that you aren't passing the correct arguments to .select(). You must pass Field ob

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-06 Thread Mark Graves
Ah! Of course. Thanks Anthony! I knew it was something dumb i did =) -Mark On Wed, Apr 6, 2016 at 11:35 AM, Anthony wrote: > table = db.auth_user >> fields = ['id','first_name'] >> fields.append('test_field_1') >> >> query = table.id > 0 >> >> row = db(query).select(*fiel

Re: [web2py] auth_user extra fields + row.to_dict()

2016-04-07 Thread Massimo Di Pierro
Good catch Anthony! On Wednesday, 6 April 2016 13:35:39 UTC-5, Anthony wrote: > > table = db.auth_user >> fields = ['id','first_name'] >> fields.append('test_field_1') >> >> query = table.id > 0 >> >> row = db(query).select(*fields).first().as_dict() >> > > The proble