def modify_esteem(self, data, esteem_id=None): """Create or modify an esteem object according to the specified value.""" parsed_data = self._parse_xml_to_dict(data) if esteem_id: esteem = Esteem.objects.get(id=esteem_id) else: esteem = Esteem() try: user_id = self._get_id_from_atom_link(parsed_data['user']) user = User.objects.get(id=user_id) esteem.user = user esteem.value = parsed_data['value'] esteem.save() return esteem except User.DoesNotExist: raise InvalidDataException("The user provided does not exist (id: %s)" % (user_id)) except KeyError, e: raise InvalidDataException("The data sent was missing an attribute!")