>
>         auth.user.challenge.writable=True     

First, you're working with the wrong object there. auth.user is just a Row 
object holding the db.auth_user record of the current logged in user. It's 
keys/attributes hold values, not DAL Fields -- so it doesn't make sense to 
set "writable" attributes on them. Instead, you probably want to work with 
the db.auth_user table and its fields. Actually, given that the error 
message refers to a Table object, I assume you did use db.auth_user in the 
real code and the above is a typo.

Second, in Python, you can't use variables to access attributes of objects 
via dot syntax as above. In general, you would use the getattr() function 
for that:

getattr(db.auth_user, challenge).writable = True

However, in this case, db.auth_user is a Table object, and its fields can 
be accessed like a dictionary:

db.auth_user[challenge].writable = True

You'll have the same problem with the subsequent row.challenge, which 
should instead be row[challenge] (note, a Row object also acts like a 
dictionary).

A couple other problems. First, there isn't actually any need to set the 
writable attribute of the challenge field -- that attribute only determines 
whether the field is made writable in SQLFORM's, which you are not using 
here -- it doesn't affect inserts and updates done outside of forms, as in 
this case. Second, there is no need to first retrieve the record and then 
update the field value -- instead, just do a direct update:

db(db.auth_user.id == team).update(**{challenge: True})

Note, because the field name is in a variable, we have to update using a 
dictionary constructed via the {} notation (for more details, see 
here<http://web2py.com/books/default/chapter/29/06#Inserting-and-updating-from-a-dictionary>
).

Another method is:

db.auth_user(team) = {challenge: True}

Anthony

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to