I think I figured out...

The problem was how I select the record. I adapted this code from the book 
without understanding it thoroughly (chapter 3, the image blog section):

db.auth_criteria.user_id.default = auth.user.id
record = db.auth_criteria(db.auth_criteria.user_id.default)

It was fine with the first few users, when user_id equals the line number 
and the table id `auth_criteria.id`. As user base grows, they are not equal 
anymore, my problem showed up. Since the record is not referencing the 
right user_id.

I should replace the two lines with this line:

record = db.auth_criteria(db.auth_criteria.user_id==auth.user.id)


This is the right way to select a record.

Sorry that I answered my own question. Hope it's useful for some other 
people who are puzzled about referencing tables.

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

Reply via email to