@never_cache
@render_to('splunkdj:page_config.html', mimetype="application/javascript")
@login_required
def get_page_config(request):
    referer = request.META.get("HTTP_REFERER", "")
    app = ""
    app_label = ""
    if referer:
        try:
            parsed = urlparse(referer)
            parsed_path = parsed.path.replace("/%s/" % settings.MOUNT, "/")
            resolved = resolve(parsed_path)
            app = resolved.app_name
            
            if app:
                app_label = request.service.apps[app]["label"]
        except Exception, e:
            # If there was an error here, don't kill the entire page
            # just return some default info
            app = app or ""
            app_label = app_label or app
    
    zone_info = request.service.get('/services/search/timeparser/tz').body.read()
    
    return {
        "autoload": "1" == request.GET.get("autoload", "0"),
        "config": json.dumps({
            "SPLUNKD_FREE_LICENSE": request.user.is_free,
            "MRSPARKLE_ROOT_PATH": "/%s" % str(settings.SPLUNK_WEB_MOUNT).strip("/"),
            "DJANGO_ROOT_PATH": "/%s" % str(settings.RAW_MOUNT),
            "MRSPARKLE_PORT_NUMBER": str(settings.SPLUNK_WEB_PORT),
            "DJANGO_PORT_NUMBER": str(settings.DJANGO_PORT),
            "LOCALE": str(request.LANGUAGE_CODE),
            "JS_LOGGER_MODE": "None",
            "USERNAME": str(request.user.username),
            "USER_DISPLAYNAME": str(request.user.realname),
            "APP": str(app),
            "APP_DISPLAYNAME": str(app_label),
            "SERVER_ZONEINFO": str(zone_info),
        })
    }
dataset/ETHPy150Open splunk/splunk-webframework/server/splunkdj/views.py/get_page_config/original