本文整理汇总了Python中django.utils.http.limited_parse_qsl方法的典型用法代码示例。如果您正苦于以下问题:Python http.limited_parse_qsl方法的具体用法?Python http.limited_parse_qsl怎么用?Python http.limited_parse_qsl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.http
的用法示例。
在下文中一共展示了http.limited_parse_qsl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django.utils import http [as 别名]
# 或者: from django.utils.http import limited_parse_qsl [as 别名]
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
示例2: infer_identifier
# 需要导入模块: from django.utils import http [as 别名]
# 或者: from django.utils.http import limited_parse_qsl [as 别名]
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')
示例3: __init__
# 需要导入模块: from django.utils import http [as 别名]
# 或者: from django.utils.http import limited_parse_qsl [as 别名]
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
示例4: __init__
# 需要导入模块: from django.utils import http [as 别名]
# 或者: from django.utils.http import limited_parse_qsl [as 别名]
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