python 2.7 - Update with pull in MongoDB 3.2.5 matching but not modifying document -
i getting 500 error on getjson request maps python 2.7 function containing mongodb update $pull.
last error seen sudo tail -f /var/log/apache2/error.log is:
[wsgi:error] [pid 1721:tid 140612911712000] [client 127.0.0.1:59078] keyerror: 'nmodified', referer: http://localhost/control_room the python logic deals particular key update $pull:
update_with_pull = collection.update({"user_email":user_email,"top_level.year":entry_year,"top_level.month":entry_month}, { "$pull": {dynamic_nested_key: {"timestamp":entry_timestamp}}}) the conditional after trying catch if document has been modified or not with:
if update_with_pull['nmodified'] == 1: #do stuff i tested same operation in mongo shell , returned:
writeresult({ "nmatched" : 1, "nupserted" : 0, "nmodified" : 0 }) so seems matching query not doing modifications.
to further troubleshoot, entry_timestamp value used in $pull section above consistent in database , function (ie both strings same characters).
some ideas:
- i've moved application
2.6.113.2.5mongodb environment, may causing problem, but, if so, haven't been able ascertain how yet. - the syntax
$pullhas changed in3.2.5? - there permission issues on collection preventing modification?
- i'm running
pymongo 2.6.2invirtualenv- perhaps has incompatibilities mongodb3.2.5?
solution
upgrading pymongo 3.2.2 causes error:
serverselectiontimeouterror: no servers found yet https://stackoverflow.com/a/31194981/1063287
however, upgraded pymongo 2.8, restarted apache , problem seems resolved.
Comments
Post a Comment