Skip to content

Commit a4192ed

Browse files
Removed json imports for 2.5 compatibility
git-svn-id: https://constituencyvolunteernetwork.googlecode.com/svn/trunk@29 220e2412-9961-11de-a05d-3bd73e269465
1 parent 09e28e0 commit a4192ed

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

signup/geo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import math
22
import twfy
3-
import json, urllib
3+
import urllib
4+
5+
from utils import json
46

57
def haversine((lat1, lon1), (lat2, lon2)):
68
"""

signup/twfy.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import urllib
22
import copy
33

4-
try:
5-
import json
6-
except ImportError:
7-
import simplejson as json
8-
4+
from utils import json
95

106
api_key = "FH8qJGE5t7opGVTuXTDumuUK"
117
service_url = "http://www.theyworkforyou.com/api/"
@@ -81,7 +77,7 @@ def getConstituencies(**kw):
8177

8278
params = dict((k, v) for k,v in kw.items() if v != None)
8379
headers, result = fetch(svcurl("getConstituencies", params))
84-
return [x['name'].decode(charset(headers)) for x in eval(result)]
80+
return [x['name'].decode(charset(headers)) for x in json.loads(result)]
8581

8682

8783
def getGeometry(name=None):

utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
from cgi import parse_qs
33
import urllib
44

5+
try:
6+
import json
7+
except ImportError:
8+
import simplejson as json
9+
10+
511
def addToQueryString(orig, extra_data):
612
scheme, netloc, path, params, query, fragment = urlparse(orig)
713
query_data = parse_qs(query)

0 commit comments

Comments
 (0)