jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] api: Use query module explicitly ......................................................................
[IMPROV] api: Use query module explicitly
When there is a query module and action module with the same name the ParamInfo module is with a4951559 able to differentiate between both. With this change ParamInfo chooses the action module if the query module wasn't chosen explicitly using the module path instead of module name.
To avoid future problems with ambiguous names this patch is explicitly using the full module path. So this will make it easier to deprecate the implicit query module selection.
Change-Id: I9e7f8d15d2b469c312c599437b1d44509e9281a7 --- M pywikibot/data/api.py M tests/api_tests.py 2 files changed, 8 insertions(+), 6 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved XZise: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 9a9c030..9bd5c7d 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1785,8 +1785,8 @@ # Default values will only cause more requests and make the query # slower. for module in limited_modules: - param = self.site._paraminfo.parameter(module, 'limit') - prefix = self.site._paraminfo[module]['prefix'] + param = self.site._paraminfo.parameter('query+' + module, 'limit') + prefix = self.site._paraminfo['query+' + module]['prefix'] if self.site.logged_in() and self.site.has_right('apihighlimits'): self.request[prefix + 'limit'] = int(param['highmax']) else: @@ -1795,7 +1795,7 @@ self.api_limit = None
if self.limited_module: - self.prefix = self.site._paraminfo[self.limited_module]['prefix'] + self.prefix = self.site._paraminfo['query+' + self.limited_module]['prefix'] self._update_limit()
if self.api_limit is not None and "generator" in kwargs: @@ -1852,7 +1852,8 @@
def _update_limit(self): """Set query limit for self.module based on api response.""" - param = self.site._paraminfo.parameter(self.limited_module, 'limit') + param = self.site._paraminfo.parameter('query+' + self.limited_module, + 'limit') if self.site.logged_in() and self.site.has_right('apihighlimits'): self.api_limit = int(param["highmax"]) else: @@ -1876,7 +1877,8 @@ if the API module does not support multiple namespaces """ assert(self.limited_module) # some modules do not have a prefix - param = self.site._paraminfo.parameter(self.limited_module, 'namespace') + param = self.site._paraminfo.parameter('query+' + self.limited_module, + 'namespace') if not param: pywikibot.warning(u'{0} module does not support a namespace ' 'parameter'.format(self.limited_module)) diff --git a/tests/api_tests.py b/tests/api_tests.py index 8a495fc..af16ba0 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -554,7 +554,7 @@ """Set up test case.""" super(TestDryListGenerator, self).setUp() mysite = self.get_site() - mysite._paraminfo['allpages'] = { + mysite._paraminfo['query+allpages'] = { 'prefix': 'ap', 'limit': {'max': 10}, 'namespace': {'multi': True}
pywikibot-commits@lists.wikimedia.org