Application Framework Reference

Module Controller API

generateResults()

The generateResults() method is called by the app server to generate module HTML content in response to a GET request.

The base class method is not implemented. Override generateResults() to provide module-specific content information.

The args parameter is a dictionary of all URI query string parameters that can be passed from the UI. The response HTML fragment is returned with the method call.

By default, the getResults() method retrieves data produced by generateResults(), using the @route() decorator.

Synopsis

results = generateResults(args)

Parameters

args

Dict

Dictionary of URI name-value pair GET request parameters.

Example:

args['host_app'] = host_app_value

Return Value

String

Success: The HTML fragment to render.

Error: Error message.

Default error message: 'This module does not have a registered renderer.'

Exceptions

User-defined, as needed.

Example

Overridden
    def generateResults(self, host_app=None, client_app=None, savedSearchName=None):

        if savedSearchName: 
            jsonSearch = None
            owner = 'nobody'
            try: 
                savedSearchObject =
                    splunk.search.getSavedSearch(label = savedSearchName,
                        namespace = client_app,
                        owner = owner)

                jsonSearch =
                    splunk.appserver.mrsparkle.util.resurrectFromSavedSearch(
                        savedSearchObject = savedSearchObject,
                        hostPath = splunk.mergeHostPath(),
                        namespace = client_app,
                        owner = owner)
        
                job = splunk.search.getJobForSavedSearch(
                    savedSearchName,
                    namespace=client_app,
                    owner=owner,
                    search='name=scheduler*')

                if (job):
                    jsonSearch["job"] = job.toJsonable(timeFormat='unix')

                return json.dumps(jsonSearch)

            except Exception, e:
                logger.exception(e)
                return ""
        else:
            logger.warn('savedSearchName was not passed from the caller')
            return ""

See Also

ModuleController.renderModule()
Splunk.Module.getResults()
@route()