def register(): form = RegistrationForm() if form.validate_on_submit(): profile = RegistrationProfile() profile.first_name = unicode(form.first_name.data) profile.last_name = unicode(form.last_name.data) profile.email = unicode(form.email.data) profile.password = unicode(generate_password_hash(form.password.data)) profile.ip_address = unicode(request.remote_addr) profile.dob = form.dob.data profile.identifier_id= unicode(form.identifier_id.data) profile.country = unicode(form.country.data) profile.zipcode = unicode(form.zipcode.data) profile.city = unicode(form.city.data) profile.street = unicode(form.street.data) profile.username = profile.email db_session.add(profile) db_session.commit() # TODO, send email! with mail.record_messages() as outbox: msg = Message("IALT Registration", sender=("IALT Registration", "*****@*****.**"), recipients=[profile.email]) msg.body = "Please activate your Profile under {0}".format(profile.activation_key) mail.send(msg) assert len(outbox) == 1 assert outbox[0].subject == "IALT Registration" assert profile.email in outbox[0].recipients flash("Registration completed. We've sent you an E-Mail with your activation key.") print profile.activation_key return redirect(url_for('index')) return render_template("auth/register.html", form=form)