@@ -27,7 +27,7 @@ class AtomicLineListClass(BaseQuery):
27
27
28
28
def __init__ (self ):
29
29
super (AtomicLineListClass , self ).__init__ ()
30
- self .__default_form_values = self . _default_form_values ()
30
+ self .__default_form_values = None
31
31
32
32
def query_object (self , * , wavelength_range = None , wavelength_type = None , wavelength_accuracy = None , element_spectrum = None ,
33
33
minimal_abundance = None , depl_factor = None , lower_level_energy_range = None ,
@@ -179,7 +179,7 @@ def query_object_async(self, *, wavelength_range=None, wavelength_type='', wavel
179
179
response : `requests.Response`
180
180
The HTTP response returned from the service.
181
181
"""
182
- default_values = self .__default_form_values
182
+ default_values = self ._default_form_values ()
183
183
wltype = (wavelength_type or default_values .get ('air' , '' )).lower ()
184
184
if wltype in ('air' , 'vacuum' ):
185
185
air = wltype .capitalize ()
@@ -290,7 +290,7 @@ def _submit_form(self, input_data=None, cache=True):
290
290
input_data = {}
291
291
# only overwrite payload's values if the ``input_data`` value is not None
292
292
# to avoid overwriting of the form's default values
293
- payload = self .__default_form_values .copy ()
293
+ payload = self ._default_form_values () .copy ()
294
294
for k , v in input_data .items ():
295
295
if v is not None :
296
296
payload [k ] = v
@@ -302,14 +302,17 @@ def _submit_form(self, input_data=None, cache=True):
302
302
return response
303
303
304
304
def _default_form_values (self ):
305
- response = self ._request ("GET" , url = self .FORM_URL , params = {},
306
- timeout = self .TIMEOUT , cache = False )
307
- bs = BeautifulSoup (response .text , features = 'html5lib' )
308
- form = bs .find ('form' )
309
- default_form_values = self ._get_default_form_values (form )
310
- self ._form_action_url = urlparse .urljoin (self .FORM_URL , form .get ('action' ))
311
-
312
- return default_form_values
305
+ if self .__default_form_values is None :
306
+ response = self ._request ("GET" , url = self .FORM_URL , params = {},
307
+ timeout = self .TIMEOUT , cache = False )
308
+ bs = BeautifulSoup (response .text , features = 'html5lib' )
309
+ form = bs .find ('form' )
310
+ default_form_values = self ._get_default_form_values (form )
311
+ self ._form_action_url = urlparse .urljoin (self .FORM_URL , form .get ('action' ))
312
+ self .__default_form_values = default_form_values
313
+ else :
314
+ raise ValueError (self .__default_form_values )
315
+ return self .__default_form_values
313
316
314
317
def _get_default_form_values (self , form ):
315
318
"""Return the already selected values of a given form (a BeautifulSoup
0 commit comments