Browse Source

HUE-1787 [sqoop2] python 2.4 json encoding issues

Abraham Elmahrek 12 years ago
parent
commit
d8d8273f35
2 changed files with 6 additions and 4 deletions
  1. 3 2
      apps/sqoop/src/sqoop/api/connection.py
  2. 3 2
      apps/sqoop/src/sqoop/api/job.py

+ 3 - 2
apps/sqoop/src/sqoop/api/connection.py

@@ -23,6 +23,7 @@ import logging
 import socket
 
 from django.http import HttpResponse
+from django.utils.encoding import smart_str
 from django.utils.translation import ugettext as _
 
 from sqoop import client, conf
@@ -64,7 +65,7 @@ def create_connection(request):
   if 'connection' not in request.POST:
     raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving connection'), data={'errors': 'Connection is missing.'}, error_code=400)
 
-  d = json.loads(request.POST['connection'])
+  d = json.loads(smart_str(request.POST['connection']))
   conn = client.Connection.from_dict(d)
 
   try:
@@ -88,7 +89,7 @@ def update_connection(request, connection):
   if 'connection' not in request.POST:
     raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving connection'), data={'errors': 'Connection is missing.'}, error_code=400)
 
-  connection.update_from_dict(json.loads(request.POST['connection']))
+  connection.update_from_dict(json.loads(smart_str(request.POST['connection'])))
 
   try:
     c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE)

+ 3 - 2
apps/sqoop/src/sqoop/api/job.py

@@ -23,6 +23,7 @@ import logging
 import socket
 
 from django.http import HttpResponse
+from django.utils.encoding import smart_str
 from django.utils.translation import ugettext as _
 
 from sqoop import client, conf
@@ -69,7 +70,7 @@ def create_job(request):
   if 'job' not in request.POST:
     raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving job'), data={'errors': 'job is missing.'}, error_code=400)
 
-  d = json.loads(request.POST['job'])
+  d = json.loads(smart_str(request.POST['job']))
   job = client.Job.from_dict(d)
 
   try:
@@ -96,7 +97,7 @@ def update_job(request, job):
   if 'job' not in request.POST:
     raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving job'), data={'errors': 'job is missing.'}, error_code=400)
 
-  job.update_from_dict(json.loads(request.POST['job']))
+  job.update_from_dict(json.loads(smart_str(request.POST['job'])))
 
   try:
     c = client.SqoopClient(conf.SERVER_URL.get(), request.user.username, request.LANGUAGE_CODE)