Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to handle a rpc call in OpenERP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 390
    Comment on it

    In OpenERP rpc help to change the post, like user want to excute two server in same systems then use rpc and change port number of other server. Basically rpc is used to run server in local systems.

    Use this function given below

    1. def rpc(service_name, method, params):
    2.  
    3. try:
    4. rpc_request = logging.getLogger(__name__ + '.rpc.request')
    5. rpc_response = logging.getLogger(__name__ + '.rpc.response')
    6. rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
    7. rpc_response_flag = rpc_response.isEnabledFor(logging.DEBUG)
    8. if rpc_request_flag or rpc_response_flag:
    9. start_time = time.time()
    10. if rpc_request and rpc_response_flag:
    11. log(rpc_request,logging.DEBUG,'%s.%s'%(service_name,method), replace_request_password(params))
    12.  
    13. result = ExportService.gedef dispatch_rpc(service_name, method, params):
    14.  
    15. try:
    16. rpc_request = logging.getLogger(__name__ + '.rpc.request')
    17. rpc_response = logging.getLogger(__name__ + '.rpc.response')
    18. rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
    19. rpc_response_flag = rpc_response.isEnabledFor(logging.DEBUG)
    20. if rpc_request_flag or rpc_response_flag:
    21. start_time = time.time()
    22. if rpc_request and rpc_response_flag:
    23. log(rpc_request,logging.DEBUG,'%s.%s'%(service_name,method), replace_request_password(params))
    24.  
    25. result = ExportService.getService(service_name).dispatch(method, params)
    26.  
    27. if rpc_request_flag or rpc_response_flag:
    28. end_time = time.time()
    29. if rpc_response_flag:
    30. log(rpc_response,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), result)
    31. else:
    32. log(rpc_request,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), replace_request_password(params), depth=1)
    33.  
    34. return result
    35. except openerp.exceptions.AccessError:
    36. raise
    37. except openerp.exceptions.AccessDenied:
    38. raise
    39. except openerp.exceptions.Warning:
    40. raise
    41. except openerp.exceptions.DeferredException, e:
    42. _logger.error(tools.exception_to_unicode(e))
    43. post_mortem(e.traceback)
    44. raise
    45. except Exception, e:
    46. _logger.error(tools.exception_to_unicode(e))
    47. post_mortem(sys.exc_info())
    48. raise
    49.  
    50. tService(service_name).dispatch(method, params)
    51.  
    52. if rpc_request_flag or rpc_response_flag:
    53. end_time = time.time()
    54. if rpc_response_flag:
    55. log(rpc_response,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), result)
    56. else:
    57. log(rpc_request,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), replace_request_password(params), depth=1)
    58.  
    59. return result
    60. except openerp.exceptions.AccessError:
    61. raise
    62. except openerp.exceptions.AccessDenied:
    63. raise
    64. except openerp.exceptions.Warning:
    65. raise
    66. except openerp.exceptions.DeferredException, e:
    67. _logger.error(tools.exception_to_unicode(e))
    68. post_mortem(e.traceback)
    69. raise
    70. except Exception, e:
    71. _logger.error(tools.exception_to_unicode(e))
    72. post_mortem(sys.exc_info())
    73. raise
    74.  
    75.  

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: