def __isub__(self, other): try: self._query.update['$inc'][str(self)] -= other except KeyError: self._query and dict_update(self._query.update, {'$inc': {str(self): -other}}) #prevent for setting a value return IgnoreValue
def __setattr__(self, key, value): if key[0] == '_': object.__setattr__(self, key, value) elif value is not IgnoreValue: parent_key = str(self) if parent_key: key = parent_key + '.' + key self._query and dict_update(self._query.update, {'$set': {key: value}})
def __delattr__(self, item): parent_key = str(self) if parent_key: item = parent_key + '.' + item self._query and dict_update(self._query.update, {'$unset': {item: ''}})