def changePass(request):
    
    response = ResponseObject()
    oldPass = request.POST.get('oldPassword')
    newPass1 = request.POST.get('newPassword1')
    newPass2 = request.POST.get('newPassword2')
    
    if not newPass1 == newPass2 and request.user.check_password(oldPass):
        response.addErrors("Your old password was not entered correctly or your new passwords don't match. Please try again")
        return response.send()
    
    request.user.set_password(newPass1)
    request.user.save()
    return response.send()
def generic_exception_handler(request, exception):
    from webservice_tools.response_util import ResponseObject
    from django.db import transaction

    response = ResponseObject()
    _, _, tb = sys.exc_info()
    # we just want the last frame, (the one the exception was thrown from)
    lastframe = get_traceback_frames(tb)[-1]
    location = "%s in %s, line: %s" % (lastframe["filename"], lastframe["function"], lastframe["lineno"])
    response.addErrors([exception.message, location])
    logger = logging.getLogger("webservice")
    logger.debug([exception.message, location])
    if transaction.is_dirty():
        transaction.rollback()
    return HttpResponse(simplejson.dumps(response.send()._container), status=500)