Python django.utils.http.limited_parse_qsl() Examples

The following are 5 code examples for showing how to use django.utils.http.limited_parse_qsl(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.utils.http , or try the search function .

Example 1
Project: bioforum   Author: reBiocoder   File: request.py    License: MIT License 6 votes vote down vote up
def __init__(self, query_string=None, mutable=False, encoding=None):
        super().__init__()
        if not encoding:
            encoding = settings.DEFAULT_CHARSET
        self.encoding = encoding
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': encoding,
        }
        if isinstance(query_string, bytes):
            # query_string normally contains URL-encoded data, a subset of ASCII.
            try:
                query_string = query_string.decode(encoding)
            except UnicodeDecodeError:
                # ... but some user agents are misbehaving :-(
                query_string = query_string.decode('iso-8859-1')
        for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
            self.appendlist(key, value)
        self._mutable = mutable 
Example 2
Project: mangaki   Author: mangaki   File: 0088_auto_20171225_1534.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def infer_identifier(url, source):
    if source == 'MAL':
        # structure is: protocol://myanimelist.net/(type)/(identifier)
        return int(url.split('/')[4])
    elif source == 'AniDB':
        _, _, _, query_encoded, _ = _urlsplit(url)
        query_params = dict(limited_parse_qsl(query_encoded))
        return query_params.get('aid', None)
    elif source == 'Manga-News':
        # structure is: protocol://www.manga-news.com/index.php/serie/(identifier)
        return url.split('/')[5]
    elif source == 'Icotaku':
        # structure is: protocol://anime.icotaku.com/anime/(identifier)/(name)
        return int(url.split('/')[4])
    elif source == 'Animeka':
        # structure is
        # protocol://www.animeka.com/animes/detail/(identifier).html
        return url.split('/')[5][:-5]
    elif source == 'VGMdb':
        # structure is the same as MAL.
        return int(url.split('/')[4])
    else:
        raise ValueError('Unknown source') 
Example 3
Project: Hands-On-Application-Development-with-PyCharm   Author: PacktPublishing   File: request.py    License: MIT License 6 votes vote down vote up
def __init__(self, query_string=None, mutable=False, encoding=None):
        super().__init__()
        self.encoding = encoding or settings.DEFAULT_CHARSET
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': self.encoding,
        }
        if isinstance(query_string, bytes):
            # query_string normally contains URL-encoded data, a subset of ASCII.
            try:
                query_string = query_string.decode(self.encoding)
            except UnicodeDecodeError:
                # ... but some user agents are misbehaving :-(
                query_string = query_string.decode('iso-8859-1')
        for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
            self.appendlist(key, value)
        self._mutable = mutable 
Example 4
Project: python   Author: Yeah-Kun   File: request.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, query_string=None, mutable=False, encoding=None):
        super(QueryDict, self).__init__()
        if not encoding:
            encoding = settings.DEFAULT_CHARSET
        self.encoding = encoding
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': encoding,
        }
        if six.PY3:
            if isinstance(query_string, bytes):
                # query_string normally contains URL-encoded data, a subset of ASCII.
                try:
                    query_string = query_string.decode(encoding)
                except UnicodeDecodeError:
                    # ... but some user agents are misbehaving :-(
                    query_string = query_string.decode('iso-8859-1')
            for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
                self.appendlist(key, value)
        else:
            for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
                try:
                    value = value.decode(encoding)
                except UnicodeDecodeError:
                    value = value.decode('iso-8859-1')
                self.appendlist(force_text(key, encoding, errors='replace'),
                                value)
        self._mutable = mutable 
Example 5
Project: python2017   Author: bpgc-cte   File: request.py    License: MIT License 5 votes vote down vote up
def __init__(self, query_string=None, mutable=False, encoding=None):
        super(QueryDict, self).__init__()
        if not encoding:
            encoding = settings.DEFAULT_CHARSET
        self.encoding = encoding
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': encoding,
        }
        if six.PY3:
            if isinstance(query_string, bytes):
                # query_string normally contains URL-encoded data, a subset of ASCII.
                try:
                    query_string = query_string.decode(encoding)
                except UnicodeDecodeError:
                    # ... but some user agents are misbehaving :-(
                    query_string = query_string.decode('iso-8859-1')
            for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
                self.appendlist(key, value)
        else:
            for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
                try:
                    value = value.decode(encoding)
                except UnicodeDecodeError:
                    value = value.decode('iso-8859-1')
                self.appendlist(force_text(key, encoding, errors='replace'),
                                value)
        self._mutable = mutable