python direct web remoting client
required requests
DWR_HOST = 'https://www.example.com'
DWR_PARAMS = {'callCount':'1',
'nextReverseAjaxIndex':'0',
'c0-id':'0',
'instanceId':'0'}
dwr = DWRClient(requests.Session(), DWR_HOST)
dwr.set_params(DWR_PARAMS)
dwr.set_page(DWR_HOST) #set page in dwr params
initialize dwr.
get session id and set session.
- script : script name default :
__System
- method : method name default :
generateId
dwr.init()
convert dictionary params to dwr param string.
return dwr params string
- params : dictionary ex)
{‘callCount’:’1’}
dwr.dumps({'a':'1', 'b':'2' })
return string
a=1
b=2
initialize batchId=0
reset session for another callflow
dwr.reset()
- page : string ex)
’/path/name'
dwr.set_page('/path/name')
- script : script name
- method : method name
- args : arguments list with converting
string:
ex)[‘0’, ‘1’]
- extra_params : add params which set using set_params() in this request
- url : url (optional) default :
/dwr/call/plaincall/script.method
dwr.request('dwrScript','method', ['1','2'])
return requests response
same request params
- script : script name
- method : method name
- args : arguments list with converting
string:
ex)[‘0’, ‘1’]
- extra_params : add params which set using set_params() in this request
- url : url (optional) default :
/dwr/call/plaincall/script.method
dwr.call('dwrScript','method', ['1','2'])
return dwr result parsing callback output
DWR_HOST = 'https://www.example.com'
DWR_PARAMS = {'callCount':'1',
'nextReverseAjaxIndex':'0',
'c0-id':'0',
'instanceId':'0'}
dwr = DWRClient(requests.Session(), DWR_HOST)
dwr.set_params(DWR_PARAMS)
dwr.set_page(DWR_HOST) #set page in dwr params
dwr.init()
res = dwr.request('dwrScript','method', ['1','2'])
'''
<Response [200]>
print(res.content)
>>>throw '~~~
dwr.engine.remote.handleCallback("0", "0", "
RESULT");
'''
dwr.call('dwrScript','method', ['1','2'])
'''
"RESULT"
'''
dwr.call('dwrScript','method1', ['1','2'])
dwr.set_page('/script/')
dwr.reset()
dwr.call('dwrScript1','method', ['1','2'])