@@ -55,9 +55,10 @@ class SchemaValidationError(FedexBaseServiceException):
5555
5656 def __init__ (self , fault ):
5757 self .error_code = - 1
58- self .value = "suds encountered an error validating your data against this service's WSDL schema. Please double-check for missing or invalid values, filling all required fields."
58+ self .value = "suds encountered an error validating your data against this service's WSDL schema. " \
59+ "Please double-check for missing or invalid values, filling all required fields."
5960 try :
60- self .value += ' Details: {}' .format (fault . detail . desc )
61+ self .value += ' Details: {}' .format (fault )
6162 except AttributeError :
6263 pass
6364
@@ -100,7 +101,8 @@ def __init__(self, config_obj, wsdl_name, *args, **kwargs):
100101 self .logger .info ("Using production server." )
101102 self .wsdl_path = os .path .join (config_obj .wsdl_path , wsdl_name )
102103
103- self .client = Client ('file:///%s' % self .wsdl_path .lstrip ('/' ))
104+ self .client = Client ('file:///%s' % self .wsdl_path .lstrip ('/' ), faults = True )
105+ #self.client.options.cache.clear() # Clear the cache, then re-init client when changing wsdl file.
104106
105107 self .VersionId = None
106108 """@ivar: Holds details on the version numbers of the WSDL."""
@@ -117,7 +119,7 @@ def __init__(self, config_obj, wsdl_name, *args, **kwargs):
117119 """@ivar: Holds customer-specified transaction IDs."""
118120
119121 self .__set_web_authentication_detail ()
120- self .__set_client_detail ()
122+ self .__set_client_detail (* args , ** kwargs )
121123 self .__set_version_id ()
122124 self .__set_transaction_detail (* args , ** kwargs )
123125 self ._prepare_wsdl_objects ()
@@ -136,9 +138,14 @@ def __set_web_authentication_detail(self):
136138 # Encapsulates the auth credentials.
137139 WebAuthenticationDetail = self .client .factory .create ('WebAuthenticationDetail' )
138140 WebAuthenticationDetail .UserCredential = WebAuthenticationCredential
141+
142+ # Set Default ParentCredential
143+ if hasattr (WebAuthenticationDetail , 'ParentCredential' ):
144+ WebAuthenticationDetail .ParentCredential = WebAuthenticationCredential
145+
139146 self .WebAuthenticationDetail = WebAuthenticationDetail
140147
141- def __set_client_detail (self ):
148+ def __set_client_detail (self , * args , ** kwargs ):
142149 """
143150 Sets up the ClientDetail node, which is required for all shipping
144151 related requests.
@@ -150,14 +157,29 @@ def __set_client_detail(self):
150157 ClientDetail .IntegratorId = self .config_obj .integrator_id
151158 if hasattr (ClientDetail , 'Region' ):
152159 ClientDetail .Region = self .config_obj .express_region_code
160+
161+ client_language_code = kwargs .get ('client_language_code' , None )
162+ client_locale_code = kwargs .get ('client_locale_code' , None )
163+
164+ if hasattr (ClientDetail , 'Localization' ) and (client_language_code or client_locale_code ):
165+ Localization = self .client .factory .create ('Localization' )
166+
167+ if client_language_code :
168+ Localization .LanguageCode = client_language_code
169+
170+ if client_locale_code :
171+ Localization .LocaleCode = client_locale_code
172+
173+ ClientDetail .Localization = Localization
174+
153175 self .ClientDetail = ClientDetail
154176
155177 def __set_transaction_detail (self , * args , ** kwargs ):
156178 """
157179 Checks kwargs for 'customer_transaction_id' and sets it if present.
158180 """
159181
160- customer_transaction_id = kwargs .get ('customer_transaction_id' , False )
182+ customer_transaction_id = kwargs .get ('customer_transaction_id' , None )
161183 if customer_transaction_id :
162184 TransactionDetail = self .client .factory .create ('TransactionDetail' )
163185 TransactionDetail .CustomerTransactionId = customer_transaction_id
@@ -177,7 +199,7 @@ def __set_version_id(self):
177199 self .logger .debug (VersionId )
178200 self .VersionId = VersionId
179201
180- def __prepare_wsdl_objects (self ):
202+ def _prepare_wsdl_objects (self ):
181203 """
182204 This method should be over-ridden on each sub-class. It instantiates
183205 any of the required WSDL objects so the user can just print their
@@ -218,6 +240,14 @@ def create_wsdl_object_of_type(self, type_name):
218240
219241 return self .client .factory .create (type_name )
220242
243+ def _assemble_and_send_request (self ):
244+ """
245+ This method should be over-ridden on each sub-class. It assembles all required objects
246+ into the specific request object and calls send_request.
247+ """
248+
249+ pass
250+
221251 def send_request (self , send_function = None ):
222252 """
223253 Sends the assembled request on the child object.
0 commit comments