def dumps(obj): if not isinstance(obj, dict): obj = dict(__bson_follow__=obj) return bson.dumps(all.traverse_and_encode(obj))