Browse Source

Merge pull request #372 from hbrunn/10.0-mail_sendgrid-use_json

[IMP] use json library instead of simplejson
pull/202/merge
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
f50e215a61
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mail_sendgrid/__manifest__.py
  2. 9
      mail_sendgrid/controllers/json_request.py
  3. 1
      requirements.txt

2
mail_sendgrid/__manifest__.py

@ -20,6 +20,6 @@
'installable': True,
'auto_install': False,
'external_dependencies': {
'python': ['sendgrid', 'simplejson'],
'python': ['sendgrid'],
},
}

9
mail_sendgrid/controllers/json_request.py

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import json
import logging
from odoo.http import JsonRequest, Root, Response
@ -8,12 +9,6 @@ from odoo.http import JsonRequest, Root, Response
old_get_request = Root.get_request
_logger = logging.getLogger(__name__)
try:
import simplejson
except ImportError:
_logger.error("Please install simplejson tu use mail_sendgrid module")
_logger.debug("ImportError details:", exc_info=True)
def get_request(self, httprequest):
if (httprequest.mimetype == "application/json" and
@ -45,7 +40,7 @@ class RESTJsonRequest(JsonRequest):
response['result'] = result
mime = 'application/json'
body = simplejson.dumps(response)
body = json.dumps(response)
return Response(
body, headers=[('Content-Type', mime),

1
requirements.txt

@ -1,3 +1,2 @@
premailer
simplejson
sendgrid
Loading…
Cancel
Save