| | 17 | def options_from_serviceurl(url, |
|---|
| | 18 | default_serviceport=8080, |
|---|
| | 19 | default_dispatchparamname='dispatcher'): |
|---|
| | 20 | urlparts=list(urlparse(url)) |
|---|
| | 21 | qp,idispatchparam=query_parameters(urlparts[-2], default_dispatchparamname) |
|---|
| | 22 | |
|---|
| | 23 | host=urlparts[1].split(':',1) |
|---|
| | 24 | if len(host)==2: |
|---|
| | 25 | host,port=host[0],int(host[1]) |
|---|
| | 26 | else: |
|---|
| | 27 | host,port=host[0],default_serviceport |
|---|
| | 28 | resourcepath='/'.join(urlparts[2].rsplit('/',1)[0]) |
|---|
| | 29 | resourcebasename=urlparts[2].rsplit('/',1) |
|---|
| | 30 | # [''], ['',''] ['','resource.json'] ['some/path','resource.json'] |
|---|
| | 31 | if not resourcebasename[0]: |
|---|
| | 32 | resourcebasename = ( |
|---|
| | 33 | len(resourcebasename) == 2 and resourcebasename[1] |
|---|
| | 34 | or '') |
|---|
| | 35 | else: |
|---|
| | 36 | resourcebasename=resourcebasename[1] |
|---|
| | 37 | return dict( |
|---|
| | 38 | scheme=urlparts[0], host=host, port=port, |
|---|
| | 39 | path=urlparts[2], |
|---|
| | 40 | dispatch_param=qp[idispatchparam][0], |
|---|
| | 41 | resourcepath=resourcepath, |
|---|
| | 42 | resourcebasename=resourcebasename, |
|---|
| | 43 | idispatch_param=idispatchparam) |
|---|
| | 44 | |
|---|