Skip to content

Commit d310703

Browse files
author
Dan Hilton
committed
Backported the library for use with Python2.5 via Simplejson support
1 parent ea37209 commit d310703

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

createsend/campaign.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import json
1+
try:
2+
import json
3+
except ImportError:
4+
import simplejson as json
5+
26
from createsend import CreateSendBase
37
from utils import json_to_py
48

createsend/client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import json
1+
try:
2+
import json
3+
except ImportError:
4+
import simplejson as json
5+
26
from createsend import CreateSendBase
37
from utils import json_to_py
48

createsend/list.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import urllib
2-
import json
2+
try:
3+
import json
4+
except ImportError:
5+
import simplejson as json
36
from createsend import CreateSendBase
47
from utils import json_to_py
58

createsend/segment.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import json
1+
try:
2+
import json
3+
except ImportError:
4+
import simplejson as json
25
from createsend import CreateSendBase
36
from utils import json_to_py
47

createsend/subscriber.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import json
1+
try:
2+
import json
3+
except ImportError:
4+
import simplejson as json
25
from createsend import CreateSendBase, BadRequest
36
from utils import json_to_py
47

@@ -33,15 +36,15 @@ def import_subscribers(self, list_id, subscribers, resubscribe):
3336
"Resubscribe": resubscribe }
3437
try:
3538
response = self._post("/subscribers/%s/import.json" % list_id, json.dumps(body))
36-
except BadRequest as br:
39+
except BadRequest:
3740
# Subscriber import will throw BadRequest if some subscribers are not imported
3841
# successfully. If this occurs, we want to return the ResultData property of
3942
# the BadRequest exception (which is of the same "form" as the response we'd
4043
# receive upon a completely successful import)
41-
if hasattr(br.data, 'ResultData'):
42-
return br.data.ResultData
44+
if hasattr(BadRequest.data, 'ResultData'):
45+
return BadRequest.data.ResultData
4346
else:
44-
raise br
47+
raise BadRequest
4548
return json_to_py(response)
4649

4750
def unsubscribe(self):

createsend/template.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import json
1+
try:
2+
import json
3+
except ImportError:
4+
import simplejson as json
5+
26
from createsend import CreateSendBase
37
from utils import json_to_py
48

createsend/utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import os
2-
import json
2+
try:
3+
import json
4+
except ImportError:
5+
import simplejson as json
36

47
def json_to_py(j):
58
o = json.loads(j)

0 commit comments

Comments
 (0)