This is the wrong syntax for a query: db(db.user_atom.user == self._user.id and db.user_atom.top_atom == self. _top_atom.id)
Instead of using "and", you must use "&" (see this section<http://web2py.com/books/default/chapter/29/06#Logical-operators>in the book): db((db.user_atom.user == self._user.id) & (db.user_atom.top_atom == self. _top_atom.id)) Your version is equivalent to Query1 and Query2, which in Python simply evaluates to Query2. So, your query amounts to: db(db.user_atom.top_atom == self._top_atom.id) Assuming more than one user has top_atom equal to self._top_atom.id, your query will return multiple records, and res[0] will simply select the first such record (presumably the record of user 454 in this case). Anthony On Saturday, January 12, 2013 10:26:45 AM UTC-5, molhokwai wrote: > > Hi, > > The title is my best guess for what the issue is most likely linked to... > although in this case, it's... *weirder*... > The code: > > logging.info('-------------------------------------------| %i ' % > self._user.id) > logging.info('-------------------------------------------| %s ' % > self._user.email) > res = db(db.user_atom.user == self._user.id > and db.user_atom.top_atom == self._top_atom.id).select() > logging.info('-------------------------------------------| %i ' %res > [0].user.id) > logging.info('-------------------------------------------| %s ' %res > [0].user.email) > > > ...puts out: > > INFO 2013-01-12 11:06:29,201 9_signup_forms.py:131] > -------------------------------------------| 505 > INFO 2013-01-12 11:06:29,202 9_signup_forms.py:132] > -------------------------------------------| [email protected] > INFO 2013-01-12 11:06:29,225 9_signup_forms.py:135] > -------------------------------------------| 454 > INFO 2013-01-12 11:06:29,271 9_signup_forms.py:136] > -------------------------------------------| [email protected] > > That is, selecting with the user with id 505 returns the record value for > user with id 454... knowing that user with id 454 is the previously created > user in the same process... > Saying this is a class reference issue is a wild guess, since this is a > variable assignment call within a method of a class instance, and not the > return of a class property for example... > > I would be grateful for a logical explanation of what is happening, and > can provide more context/code, if ncessary... > > In any case, thanks for the great framework... > > --------------- > molhokwai > > --

