Mercurial > public > bravenewsurf
changeset 62:93e9e7b3d2ae
Put in an import dance for Python 2.5. Apparently cgi.parse_qs was copied to urlparse in Python 2.6. So look for it first in urlparse, and if not found, try cgi.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Nov 2011 14:47:17 -0600 |
parents | 1d2473f4bcaa |
children | b0f4ea06c698 |
files | bns_website/videos/admin.py |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/bns_website/videos/admin.py Sat Nov 19 14:39:28 2011 -0600 +++ b/bns_website/videos/admin.py Sat Nov 19 14:47:17 2011 -0600 @@ -5,6 +5,11 @@ import datetime import urlparse +try: + from urlparse import parse_qs +except ImportError: + from cgi import parse_qs # for Python 2.5 + from django.contrib import admin from django.contrib import messages from gdata.youtube.service import YouTubeService @@ -31,7 +36,7 @@ """ # Find the playlist ID: parts = urlparse.urlparse(playlist.playlist_url) - query = urlparse.parse_qs(parts.query) + query = parse_qs(parts.query) if 'list' not in query: messages.error(request, 'Invalid playlist %s' % playlist.playlist_url) @@ -69,7 +74,7 @@ for vid in vids: for link in vid.link: parts = urlparse.urlparse(link.href) - query = urlparse.parse_qs(parts.query) + query = parse_qs(parts.query) if 'v' in query: vid_ids.append(query['v'][0]) break