Projet

Général

Profil

0001-payfip_ws-initialize-PayFiP-SOAP-client-lazily-and-e.patch

Benjamin Dauvergne, 30 avril 2021 11:21

Télécharger (1,68 ko)

Voir les différences:

Subject: [PATCH] payfip_ws: initialize PayFiP SOAP client lazily and
 encapsulate internal exceptions (#53590)

 eopayment/payfip_ws.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
eopayment/payfip_ws.py
87 87
    '''Encapsulate SOAP web-services of PayFiP'''
88 88

  
89 89
    def __init__(self, wsdl_url=None, service_url=None, zeep_client_kwargs=None):
90
        self.client = zeep.Client(wsdl_url or WSDL_URL, **(zeep_client_kwargs or {}))
91
        # distribued WSDL is wrong :/
92
        self.client.service._binding_options['address'] = service_url or SERVICE_URL
90
        self.wsdl_url = wsdl_url
91
        self.service_url = service_url
92
        self.zeep_client_kwargs = zeep_client_kwargs
93

  
94
    @property
95
    def client(self):
96
        if not hasattr(self, '_client'):
97
            try:
98
                self._client = zeep.Client(self.wsdl_url or WSDL_URL, **(self.zeep_client_kwargs or {}))
99
                # distribued WSDL is wrong :/
100
                self._client.service._binding_options['address'] = self.service_url or SERVICE_URL
101
            except Exception as e:
102
                raise PayFiPError('Cound not initialize the SOAP client', e)
103
        return self._client
93 104

  
94 105
    def fault_to_exception(self, fault):
95 106
        if fault.message != 'fr.gouv.finances.cp.tpa.webservice.exceptions.FonctionnelleErreur' or fault.detail is None:
96
-