[1.7.x] Replaced urllib/urlparse imports with from django.utils.six.moves.

Backport of 981b864fbd from master
This commit is contained in:
Tim Graham 2014-03-31 07:54:22 -04:00
parent 5268d71f18
commit 07c42cee7f
4 changed files with 4 additions and 15 deletions

View File

@ -1,12 +1,8 @@
try:
from urllib.parse import parse_qsl, urlparse, urlunparse
except ImportError:
from urlparse import parse_qsl, urlparse, urlunparse
from django import template from django import template
from django.contrib.admin.utils import quote from django.contrib.admin.utils import quote
from django.core.urlresolvers import Resolver404, get_script_prefix, resolve from django.core.urlresolvers import Resolver404, get_script_prefix, resolve
from django.utils.http import urlencode from django.utils.http import urlencode
from django.utils.six.moves.urllib.parse import parse_qsl, urlparse, urlunparse
register = template.Library() register = template.Library()

View File

@ -6,11 +6,6 @@ import re
import sys import sys
from io import BytesIO from io import BytesIO
from pprint import pformat from pprint import pformat
try:
from urllib.parse import parse_qsl, urlencode, quote, urljoin
except ImportError:
from urllib import urlencode, quote
from urlparse import parse_qsl, urljoin
from django.conf import settings from django.conf import settings
from django.core import signing from django.core import signing
@ -20,6 +15,7 @@ from django.http.multipartparser import MultiPartParser, MultiPartParserError
from django.utils import six from django.utils import six
from django.utils.datastructures import MultiValueDict, ImmutableList from django.utils.datastructures import MultiValueDict, ImmutableList
from django.utils.encoding import force_bytes, force_text, force_str, iri_to_uri from django.utils.encoding import force_bytes, force_text, force_str, iri_to_uri
from django.utils.six.moves.urllib.parse import parse_qsl, urlencode, quote, urljoin
RAISE_ERROR = object() RAISE_ERROR = object()

View File

@ -5,10 +5,6 @@ import json
import sys import sys
import time import time
from email.header import Header from email.header import Header
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
from django.conf import settings from django.conf import settings
from django.core import signals from django.core import signals
@ -20,6 +16,7 @@ from django.utils import six, timezone
from django.utils.encoding import force_bytes, force_text, iri_to_uri from django.utils.encoding import force_bytes, force_text, iri_to_uri
from django.utils.http import cookie_date from django.utils.http import cookie_date
from django.utils.six.moves import map from django.utils.six.moves import map
from django.utils.six.moves.urllib.parse import urlparse
# See http://www.iana.org/assignments/http-status-codes # See http://www.iana.org/assignments/http-status-codes

View File

@ -166,9 +166,9 @@ A :class:`ResolverMatch` object can also be assigned to a triple::
One possible use of :func:`~django.core.urlresolvers.resolve` would be to test One possible use of :func:`~django.core.urlresolvers.resolve` would be to test
whether a view would raise a ``Http404`` error before redirecting to it:: whether a view would raise a ``Http404`` error before redirecting to it::
from urlparse import urlparse
from django.core.urlresolvers import resolve from django.core.urlresolvers import resolve
from django.http import HttpResponseRedirect, Http404 from django.http import HttpResponseRedirect, Http404
from django.utils.six.moves.urllib.parse import urlparse
def myview(request): def myview(request):
next = request.META.get('HTTP_REFERER', None) or '/' next = request.META.get('HTTP_REFERER', None) or '/'