def handlePerson(self, xml_person): first_name = xml_person.get("first_name") last_name = xml_person.get("last_name") try: om_person = Person.objects.all().get(first_name=first_name, last_name=last_name) print("Person %s %s already imported" % (first_name,last_name)) return om_person except Exception: # do nothing, continue to import it om_person = None om_person = Person() om_person.first_name = first_name om_person.last_name = last_name om_person.birth_date = BIRTH_DATE_DEF om_person.sex = SEX_DEF om_person.save() return om_person
"subject": subject, "error": smart_text(e), "data": smart_text(log_data) } d = {"subject": subject} logger.warning(msg, extra=d) # continue even in case of error # create the person person = Person() person.first_name = user.first_name person.last_name = user.last_name person.birth_date = form.cleaned_data["birth_date"] person.birth_location = form.cleaned_data.get("birth_location", None) person.sex = form.cleaned_data["sex"] person.img = request.FILES.get('image', None) try: person.save() # link the extra_data object to the person extra_data.person = person extra_data.image = person.img extra_data.save() except Exception, e: subject = _( u"It was not possible to save the personal data of user: %(user)s"
subject =_(u"It was not possible to register user: %(user)s") % { "user":smart_text(user) } msg = _("%(subject)s.\n\nDetails: %(error)s\n\nProvided data:\n\n%(data)s") % { "subject": subject, "error": smart_text(e), "data": smart_text(log_data) } d = { "subject": subject } logger.warning(msg, extra=d) # continue even in case of error # create the person person = Person() person.first_name = user.first_name person.last_name = user.last_name person.birth_date = form.cleaned_data["birth_date"] person.birth_location = form.cleaned_data.get("birth_location", None) person.sex = form.cleaned_data["sex"] person.img = request.FILES.get('image', None) try: person.save() # link the extra_data object to the person extra_data.person = person extra_data.image = person.img extra_data.save() except Exception, e: subject = _(u"It was not possible to save the personal data of user: %(user)s") % { "user": smart_text(user) }