def password_reset(request):
  request.session['msg'] = "";
  if request.POST:
    try:
      # check to see if a user by the email address exists in the system
      email = request.POST['email']
      user = User.objects.get(email=email)
    
      # generate a new password
      from random import choice
      new_password = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(16)])

      # assign the new password to the user account
      user.set_password(new_password)
      user.save()

      # send the new password to that e-mail address & tell them to change their pass immediately!
      from django.core.mail import send_mail
      
      subject = '[Snipt] Here\'s a temporary password'
      message = 'Log-in using %s\r\n\r\nPlease update your password immediately after that!\r\n\r\n- Snipt.net admins' % new_password
      
      send_mail(subject, message, 'no-reply@snipt.net', [email], fail_silently=False)
      
      request.session['msg'] = "We've sent you a temporary password. Check your e-mail!"
      
    except User.DoesNotExist:
      request.session['msg'] = "We didn't find anyone registered under %s" % request.POST['email']
    
    # or asset false
    # assert False
    
  return render_to_response('password_reset.html', locals(), context_instance=RequestContext(request))
  # request.session.msg = 'your password is being worked on by the locals.'
  # home_page(request)
dataset/ETHPy150Open nicksergeant/snipt-old/views.py/password_reset/original