def download_rc_file(request):
    tenant_id = request.user.tenant_id
    tenant_name = request.user.tenant_name

    template = 'project/access_and_security/api_access/openrc.sh.template'

    try:
        keystone_url = api.base.url_for(request,
                                        'identity',
                                        endpoint_type='publicURL')

        context = {'user': request.user,
                   'auth_url': keystone_url,
                   'tenant_id': tenant_id,
                   'tenant_name': tenant_name}

        response = shortcuts.render(request,
                                    template,
                                    context,
                                    content_type="text/plain")
        response['Content-Disposition'] = ('attachment; '
                                           'filename="%s-openrc.sh"'
                                           % tenant_name)
        response['Content-Length'] = str(len(response.content))
        return response

    except Exception as e:
        LOG.exception("Exception in DownloadOpenRCForm.")
        messages.error(request, _('Error Downloading RC File: %s') % e)
        return shortcuts.redirect(request.build_absolute_uri())
dataset/ETHPy150Open Havate/havate-openstack/proto-build/gui/horizon/Horizon_GUI/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py/download_rc_file/original