def index(self, autoload=False): if autoload: cherrypy.response.headers['Content-type'] = MIME_JAVASCRIPT else: cherrypy.response.headers['Content-type'] = splunk.appserver.mrsparkle.MIME_JSON # don't expose any data if user is not logged in if not cherrypy.session.get('sessionKey'): return "" # TODO: cache this data time_begin = time.time() output = i18n.get_all_translations_cached(locale=None, autoload=autoload) # locale=None uses cherrypy current locale time_translations_retrieved = time.time() useBrowserCache = util.apply_etag(output) time_etag_calculated = time.time() logger.info("i18ncatalog: translations_retrieved=%s etag_calculated=%s overall=%s" % ( time_translations_retrieved - time_begin, time_etag_calculated - time_translations_retrieved, time_etag_calculated - time_begin)) if useBrowserCache: return None return output
def index(self, autoload=False, namespace=None, asDict=False): ''' Returns the configuration information for the main Splunk frontend. The values returned from the endpoint are subject to the following: 1) values are idempotent 2) any time values are in ISO-8601 format 3) values are typed appropriately On the JS side, these values are all inserted into a config dictionary that is accessible at: window.$C[<key_name>] These values should be treated as read-only. TODO: attach event handlers to value changes on JS side ''' cherrypy.response.headers['content-type'] = MIME_JSON # unauthed calls get the bare minimum if not cherrypy.session.get('sessionKey'): args = self._get_active_unauthorized_config() else: args = self._get_active_config() if namespace: args.update(self._get_app_config(namespace)) # for debug page if asDict: return args if autoload: output = 'window.$C = %s' % json.dumps(args) else: output = json.dumps(args) if util.apply_etag(output): return None else: logger.debug('config values: %s' % args) return output
def index(self, autoload=False, namespace=None, asDict=False): """ Returns the configuration information for the main Splunk frontend. The values returned from the endpoint are subject to the following: 1) values are idempotent 2) any time values are in ISO-8601 format 3) values are typed appropriately On the JS side, these values are all inserted into a config dictionary that is accessible at: window.$C[<key_name>] These values should be treated as read-only. TODO: attach event handlers to value changes on JS side """ cherrypy.response.headers["content-type"] = MIME_JSON # unauthed calls get the bare minimum if not cherrypy.session.get("sessionKey"): args = self._get_active_unauthorized_config() else: args = self._get_active_config() if namespace: args.update(self._get_app_config(namespace)) # for debug page if asDict: return args if autoload: output = "window.$C = %s" % json.dumps(args) else: output = json.dumps(args) if util.apply_etag(output): return None else: logger.debug("config values: %s" % args) return output
def apply_etag(fn, self, *a, **kw): response = fn(self, *a, **kw) if (util.apply_etag(response)): return None else: return response
def apply_etag(fn, self, *a, **kw): response = fn(self, *a, **kw) if (util.apply_etag(response)): return None else: return response