Boolean parameter refresh is broken
You can clearly see here conversion of parameter to boolean type. https://github.com/aio-libs/aioes/blob/master/aioes/client/init.py#L133 Then it fails here https://github.com/aio-libs/yarl/blob/master/yarl/init.py#L673
Considering this, there's no way to use refresh parameter at all.
Monkeypatch workaround
import yarl
original_with_query = yarl.URL.with_query
def new_with_query(self, *args, **kwargs):
if kwargs:
query = kwargs
elif len(args) == 1:
query = args[0]
if isinstance(query, Mapping) and 'refresh' in query and isinstance(query['refresh'], bool):
query['refresh'] = '1' if query['refresh'] else '0'
return original_with_query(self, *args, **kwargs)
yarl.URL.with_query = new_with_query
Would you provide a patch which fixes aioes, without yarl monkeypatching?
There're two ways of solving this problem: modifying yarl for bool support and replacing bool parameters everywhere is aioes. What can you consider correct?
The second one
Any plans on merging this and doing a new release soon?
@wintamute I would prefer to be able to convert from bool instead passing as is. refresh=True looks more reasonable than refresh=1.
@neumond I agree, I was referring to the commit above (https://github.com/DLizogub/aioes/commit/77c4d56b28f8c97f607d6d5b6c741120a4b091e6) Edit: I just checked that commit again, my bad, the fix should be to convert here to str instead of passing as is so that yarl doesn't complain later on. I didn't try it I admit. Using a local modified version doesn't really help me since I need a version the build system can just download.
A less hackish monkey-patch to workaround this issue as well as #112
from aioes.connection import Connection
__original_perform_request = Connection.perform_request
def perform_request(self, method, url, params, body):
url = url.lstrip('/') # Fixes issue #112
if params:
for key, value in params.items():
if isinstance(value, bool):
params[key] = str(value).lower()
return __original_perform_request(self, method, url, params, body)
Connection.perform_request = perform_request
Hey, guys! Please check this out with latest master!
Looks very much so. Many thanks for giving some love to ES5 support.