#NEWLINE# def getApiUrl( url = None ) : #NEWLINE# #INDENT# '\n    In a request thread, call this to get the path to the root of the REST API.\n    The returned path does *not* end in a forward slash.\n\n    :param url: URL from which to extract the base URL. If not specified, uses\n        `cherrypy.url()`\n    ' #NEWLINE# url = ( url or cherrypy . url ( ) ) #NEWLINE# idx = url . find ( '/api/v1' ) #NEWLINE# if ( idx < 0 ) : #NEWLINE# #INDENT# raise GirderException ( ( 'Could not determine API root in %s.' % url ) ) #NEWLINE# #UNINDENT# return url [ : ( idx + 7 ) ]