1

During debugging of the unittest of my Python web application using SQLAlchemy, the uber persistent user object dropped my jaw --

> myapp/views/signup.py(73)signup_view()
-> user = model.User(user_name=user_name, email=email, password=password)
(Pdb) n
(Pdb) user
<pweb.models.User object at 0xbbb20ec>
(Pdb) user = None
(Pdb) user
<pweb.models.User object at 0xbbb20ec>     <!-- !!!??? -->

(Pdb) user2 = model.User(user_name=user_name, email=email, password=password)
(Pdb) user2
<pweb.models.User object at 0xbbb2f0c>
(Pdb) user2 = None
(Pdb) user2
(Pdb) 

Similar behaviour can not be observed in stand-alone trivial script --

(Pdb) l
  1   if __name__ == '__main__':
  2       user = 1
  3       import pdb; pdb.set_trace()
  4  ->     pass
[EOF]
(Pdb) user
1
(Pdb) user = 2
(Pdb) user
2

What should the rationale be in the first example? Could it be related to the mid of transaction that is behind Python unittest (using SQLAlchemy) does not write/update database??

2
  • 1
    Can you post the definition of the User class? Commented Dec 27, 2010 at 10:28
  • Are you using Python 2.6 or lower? Might be related to a bug there, and therefore a duplicate of stackoverflow.com/questions/7912820/… Commented Oct 27, 2011 at 18:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.