Debugging code on mongodb.py