def METHOD_NAME(session, user):
    """
    Transaction for issuing password reset tokens
    :param session: An ORM session
    :param user: The user for which issuing a password reset token
    """
    token = generateRandomKey()
    if user.last_login > datetime_null():
        template = 'password_reset_validation'
    else:
        template = 'account_activation'
    user_desc = user_serialize_user(session, user, user.language)
    try:
        with open(os.path.abspath(os.path.join(State.settings.ramdisk_path, token)), "wb") as f:
            f.write(user.id.encode())
    except:
        pass
    template_vars = {
        'type': template,
        'user': user_desc,
        'reset_token': token,
        'node': db_admin_serialize_node(session, user.tid, user.language),
        'notification': db_get_notification(session, user.tid, user.language)
    }
    State.format_and_send_mail(session, user.tid, user_desc['mail_address'], template_vars)
    return token