server -> an object used to boxcar method calls server should be a ServerProxy object. Methods can be added to the MultiCall using normal method call syntax e.g.: multicall = MultiCall(server_proxy) multicall.add(2,3) multicall.get_address("Guido") To execu
| 858 | raise ValueError("unexpected type in multicall result") |
| 859 | |
| 860 | class MultiCall: |
| 861 | """server -> an object used to boxcar method calls |
| 862 | |
| 863 | server should be a ServerProxy object. |
| 864 | |
| 865 | Methods can be added to the MultiCall using normal |
| 866 | method call syntax e.g.: |
| 867 | |
| 868 | multicall = MultiCall(server_proxy) |
| 869 | multicall.add(2,3) |
| 870 | multicall.get_address("Guido") |
| 871 | |
| 872 | To execute the multicall, call the MultiCall object e.g.: |
| 873 | |
| 874 | add_result, address = multicall() |
| 875 | """ |
| 876 | |
| 877 | def __init__(self, server): |
| 878 | self.__server = server |
| 879 | self.__call_list = [] |
| 880 | |
| 881 | def __repr__(self): |
| 882 | return "<%s at %#x>" % (self.__class__.__name__, id(self)) |
| 883 | |
| 884 | def __getattr__(self, name): |
| 885 | return _MultiCallMethod(self.__call_list, name) |
| 886 | |
| 887 | def __call__(self): |
| 888 | marshalled_list = [] |
| 889 | for name, args in self.__call_list: |
| 890 | marshalled_list.append({'methodName' : name, 'params' : args}) |
| 891 | |
| 892 | return MultiCallIterator(self.__server.system.multicall(marshalled_list)) |
| 893 | |
| 894 | # -------------------------------------------------------------------- |
| 895 | # convenience functions |