def query(self, titles, pageids=None, cparams=None):
        """
        Returns MediaWiki action=query query string
        """
        query = self.QUERY.substitute(
            WIKI=self.uri,
            ENDPOINT=self.endpoint,
            TITLES=safequote(titles) or pageids)
        status = titles or pageids

        if pageids and not titles:
            query = query.replace('&titles=', '&pageids=')

        if cparams:
            query += cparams
            status += " (%s)" % cparams

        if self.variant:
            query += '&variant=' + self.variant

        self.set_status('query', status)

        return query
Returns MediaWiki action=query query string