--- XMLRpcTools/XmlRpcProxy.py 2007/11/26 20:32:58 1.4 +++ XMLRpcTools/XmlRpcProxy.py 2008/03/06 15:08:32 1.5 @@ -74,14 +74,17 @@ class XmlRpcProxyMethod(SimpleItem): rpc_arg_expr='[^A-z0-9]' + num_retries=0 + manage_options= ( {'label':'Main Config','action':'mainConfigForm'}, )+ SimpleItem.manage_options - def __init__(self,id,rpc_arg_expr=None): + def __init__(self,id,rpc_arg_expr=None,num_retries=0): """init server proxy""" self.id=id + self.num_retries = num_retries if rpc_arg_expr: self.rpc_arg_expr = rpc_arg_expr @@ -95,17 +98,29 @@ class XmlRpcProxyMethod(SimpleItem): else: args = argv - # call the method self.id on the server with the args - return getattr(server, self.id)(*args) + i = 0 + while True: + try: + # call the method self.id on the server with the args + return getattr(server, self.id)(*args) + + except: + # should we catch only specific exceptions? + if i >= self.num_retries: + # pass on exception + raise + i += 1 + __call__ = eval mainConfigForm = PageTemplateFile('zpt/manageXmlRpcProxyMethod',globals()) - def mainConfig(self,rpc_arg_expr=None,RESPONSE=None): + def mainConfig(self,rpc_arg_expr=None,num_retries=0,RESPONSE=None): """main config""" - + + self.num_retries = num_retries if rpc_arg_expr is not None: self.rpc_arg_expr = rpc_arg_expr @@ -118,9 +133,9 @@ def manage_addXmlRpcProxyMethodForm(self pt=PageTemplateFile('zpt/addXmlRpcProxyMethod',globals()).__of__(self) return pt() -def manage_addXmlRpcProxyMethod(self,id,rpc_arg_expr,RESPONSE=None): +def manage_addXmlRpcProxyMethod(self,id,rpc_arg_expr,num_retries,RESPONSE=None): """add the basket""" - ob=XmlRpcProxyMethod(id,rpc_arg_expr) + ob=XmlRpcProxyMethod(id,rpc_arg_expr,num_retries) self._setObject(id, ob) if RESPONSE is not None: