nanomongo.utilRecordingDict

RecordingDict

class nanomongo.util.RecordingDict(*args, **kwargs)[source]

A dictionary subclass modifying __setitem__() and __delitem__() methods to record changes in its __nanodiff__ attribute

check_can_update(modifier, field_name)[source]

Check if given modifier field_name combination can be added. MongoDB does not allow field duplication with update modifiers. This is to be used with methods addToSet

clean_other_modifiers(current_mod, field_name)[source]

Given current_mod, removes other field_name modifiers, eg. when called with $set, removes $unset and $addToSet etc. on field_name

get_sub_diff()[source]

get __nanodiff__ from embedded documents. Find fields of RecordingDict type, iterate over their diff and build dotted keys for top level diff

reset_diff()[source]

reset __nanodiff__ recursively; to be used after saving diffs. This does NOT do a rollback. Reload from db for that

RecordingDict.__init__(*args, **kwargs)[source]
class nanomongo.util.NanomongoSONManipulator(as_class, transforms=None)[source]

A pymongo SON Manipulator used on data that comes from the database to transform data to the document class we want because as_class argument to pymongo find methods is called in a way that screws us.

  • Recursively applied, we don’t want that
  • __init__ is not properly used but rather __setitem__, fails us

JIRA: PYTHON-175 PYTHON-215