Disable zeep cache handling when using the test server

issue5600
review20231002
This commit is contained in:
Nicolas Évrard committed 2016-06-03 17:26:55 +02:00
1 parent 8c8d9e6e2c
commit a70dc79839
3 files changed
+21 -14

No files matched your search

+2 -7
View File
@@ -1,14 +1,11 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from urlparse import urljoin
from zeep import Client
from zeep.exceptions import Fault
from trytond.config import config
from trytond.model import ModelSQL, ModelView, MatchMixin, fields
from trytond.pool import PoolMeta
from .configuration import SERVER_URLS, LOGIN_SERVICE
from .configuration import get_client, LOGIN_SERVICE
__all__ = ['CredentialDPD', 'Carrier']
@@ -40,9 +37,7 @@ class CredentialDPD(ModelSQL, ModelView, MatchMixin):
return 'testing'
def update_token(self):
api_base_url = config.get('stock_package_shipping_dpd',
self.server, default=SERVER_URLS[self.server])
auth_client = Client(urljoin(api_base_url, LOGIN_SERVICE))
auth_client = get_client(self.server, LOGIN_SERVICE)
lang = (self.company.party.lang.code
if self.company.party.lang else 'en_US')
try:
+17
View File
@@ -1,5 +1,10 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from urlparse import urljoin
from zeep import Client
from zeep.transports import Transport
from trytond.config import config
SERVER_URLS = {
'testing': 'https://public-ws-stage.dpd.com/services/',
@@ -8,3 +13,15 @@ SERVER_URLS = {
LOGIN_SERVICE = 'LoginService/V2_0?wsdl'
SHIPMENT_SERVICE = 'ShipmentService/V3_2?wsdl'
def get_client(server, service):
api_base_url = config.get('stock_package_shipping_dpd',
server, default=SERVER_URLS[server])
url = urljoin(api_base_url, service)
# Disable the cache for testing because zeep's bug
# https://github.com/mvantellingen/python-zeep/issues/48
# which makes testing environments fail
transport = (Transport(cache=None)
if url.startswith(SERVER_URLS['testing']) else None)
return Client(url, transport=transport)
+2 -7
View File
@@ -2,19 +2,16 @@
# this repository contains the full copyright notices and license terms.
from io import BytesIO
from urlparse import urljoin
from lxml import etree
from zeep import Client
from zeep.exceptions import Fault
from PyPDF2 import PdfFileReader, PdfFileWriter
from trytond.config import config
from trytond.pool import Pool, PoolMeta
from trytond.model import fields
from trytond.wizard import Wizard, StateAction, StateTransition
from trytond.transaction import Transaction
from .configuration import SERVER_URLS, SHIPMENT_SERVICE
from .configuration import get_client, SHIPMENT_SERVICE
__all__ = ['ShipmentOut', 'CreateShipping', 'CreateDPDShipping']
@@ -96,9 +93,7 @@ class CreateDPDShipping(Wizard):
if not credential.depot or not credential.token:
credential.update_token()
api_base_url = config.get('stock_package_shipping_dpd',
credential.server, default=SERVER_URLS[credential.server])
shipping_client = Client(urljoin(api_base_url, SHIPMENT_SERVICE))
shipping_client = get_client(credential.server, SHIPMENT_SERVICE)
print_options = self.get_print_options(shipment)
packages = shipment.root_packages
shipment_data = self.get_shipment_data(credential, shipment, packages)