Skip to content

Commit

Permalink
Better hierarchy for importing JSON. Simplejson is faster than the bu…
Browse files Browse the repository at this point in the history
…ilt in "json" due to the compiled C _speedups module.
  • Loading branch information
mattrobenolt committed Mar 13, 2012
1 parent 5e1df27 commit e63e64d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions postmark/core.py
Expand Up @@ -19,12 +19,16 @@
import httplib

try:
import json
import simplejson as json
except ImportError:
try:
import simplejson as json
import json
except ImportError:
raise Exception('Cannot use python-postmark library without Python 2.6 or greater, or Python 2.4 or 2.5 and the "simplejson" library')
try:
# Last ditch effort to try and grab it from Django if they're using Django
from django.utils import simplejson as json
except ImportError:
raise Exception('Cannot use python-postmark library without Python 2.6 or greater, or Python 2.4 or 2.5 and the "simplejson" library')

class PMJSONEncoder(json.JSONEncoder):
def default(self, o):
Expand Down

0 comments on commit e63e64d

Please sign in to comment.