def logged_update(self, user, data, *fields):
<EOL>original = self.comparable<EOL>_fields = fields<EOL>if len(fields) == <NUM_LIT:0>:<EOL><INDENT>_fields = data.keys()<EOL><DEDENT>for field in _fields:<EOL><INDENT>if field in data:<EOL><INDENT>setattr(self, field, data[field])<EOL><DEDENT><DEDENT>self.update(*fields)<EOL>entry = ChangeLogEntry({<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT>': [self],<EOL>'<STR_LIT:user>': user<EOL>})<EOL>entry.add_diff(original, self.comparable)<EOL>if not entry.is_diff:<EOL><INDENT>return<EOL><DEDENT>entry.insert()<EOL>return entry<EOL>
Update the document with the dictionary of data provided and log the
event in the change log.