vendredi 31 juillet 2015

Ajax call to local .py script works fine until I add a simple import at the top, upon which it fails with a 500 error

This is all happening on the Django platform. Here is my ajax call:

$.ajax({
        type: 'GET',
        url: 'get-dropdown-contents', //a url mapping to controller_ajax.py
        dataType:'json',
        data: {'selection_path': selectionPath},
        success: function (data) {
               //blah blah blah.... it doesn't reach here

Here is the .py script that is called:

from hs_restclient import HydroShare, HydroShareAuthBasic
from django.http import JsonResponse
from functions import irods_query


def get_dropdown_contents(request):
    print "Entered"
    if request.method == 'GET':
        selection_path = request.GET['selection_path']
        irods_data = irods_query(selection_path)
        return JsonResponse({
                                'success': "Response successfully returned!",
                                'irods_data': irods_data
                            })


def upload_to_hydroshare(request):
    if request.method == 'GET':
        hydro_username = request.GET['hydro_username']
        hydro_password = request.GET['hydro_password']
        try:
            print hydro_password
            print hydro_username
            hs = HydroShare(auth=HydroShareAuthBasic(username='joe', password='shmoe'))
        except Exception, err:
            print "Err: " + str(err)
            return JsonResponse({'error': 'Username or password invalid'})
        return JsonResponse({'success': 'Response successfully returned!'})

The ajax call, which calls the get_dropdown_contents() function worked perfectly fine. However, with the simple addition of the from hs_resclient import... statement, the ajax call now fails with a 500 internal server error. If I comment out that one statement, the call works without a problem. I cannot figure out why for the life of me.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire