The make_url() function returns a URL for the specified path.
The method builds a URL from a relative or absolute URL with optional query string. A relative URL is returned, if relative is set to True, otherwise, an absolute URL is returned. The string /splunk or the configuration root_path is prefixed to the URL unless translate is set to False .
Static paths are constructed with an embedded cache defeater segment :
/static/@<build_number>[.<push_number>]/
This results in static paths like the following example:
/static/@12345/js/foo/static/@12345.1/js/foo
Static assets for apps have an additional cache defeater number correlating to the application build number as defined in the app.conf file:
/static/@12345.1:2/app/unix/static/foo.png
The URL handler in root.py strips out any requests having this schema.
targURL = make_url(target, _qs=None, translate=True, relative=False, __app_cache={})
|
target |
String |
|
|
_qs |
Object |
Query string as a list of tuples or a dictionary. Example: _qs=[('q', 'search val to quote')] (Default = None ) |
|
translate |
Boolean |
Prefix the application server root path flag: True = Prefix root path (Default). False = Do not prefix root path. |
|
relative |
Boolean |
Relative returned path indication: True = Returned targetURL is relative. False = Returned targetURL is absolute (Default) |
|
String |
The specified target as a full URL. |
|
InvalidURLException |
"Illegal characters in URL" |
|
ValueError |
'Illegal escape from parent directory "%s": %s' %(basepath, fullpath) |
from splunk.appserver.mrsparkle.lib import util
targetURL = '/en-US/api/search/jobs?job=1234&action=delete'
example1URL = util.make_url('/api/search/jobs', job=1234, action=delete)
example2URL = util.make_url('/api/search/jobs, _qs=dict(job=1234,action=delete))