0

I'm using ExtJs 4.2.2 on Windows and I'm willing to execute a python script to load my json data. I'm following the example in the documentation and I'm facing an error I can't understand : my store doesn't seem to execute my python script to get a response, instead it tries to load my source code as a json file.

test.py :

#!C:\Python27\python.exe
import json
print "Content-type: application/json\n\n"
print("{\"text\":\".\",\"UserStories\":[{\"id\": \"1\", \"State\":\"hello\", \"headline\": \"world\", \"category\": \"rien\"}]}")

my store TreeGrid.js:

Ext.define
(
    'CMS.store.TreeGrid', 
    {
        extend: 'Ext.data.TreeStore',

        model: 'CMS.model.TreeGrid',
        storeId: 'TreeGrid',
        autoLoad: false,
        autoSync: true,
        proxy: 
        {
            type: 'ajax',
            url: 'pythonScripts/test.py',

            reader:
            {
                type: 'json',
                root: 'UserStories'
            },

        },
        folderSort: true
    }
);

the function in my controller :

 onRequest: function()
    {
         var myStore = this.getTreeGridStore();
         myStore.load
         (
              {
                    scope: this
               }
         );
        Ext.Ajax.request
            (
                {
                    url: 'pythonScripts/test.py',
                    success: function(response, opts) 
                    {
                        var obj = Ext.decode(response.responseText);
                        console.dir(obj);
                    },
                    failure: function(response, opts) 
                    {
                        console.dir('server-side failure with status code ' + response.status);
                    }
                }
            );
}

And here is the response I get on FireBug: http://www.sencha.com/forum/attachment.php?attachmentid=46630&d=1383130677

I just can't get why it's not executing the script but tries to get the raw code in it. Any help would be appreciated, thank you.

Nightfirecat
  • 11,432
  • 6
  • 35
  • 51
Toussah
  • 245
  • 1
  • 3
  • 14
  • Do you have Pyhton interpreter installed on your web server? – Krzysztof Oct 30 '13 at 12:17
  • I'm testing my application on my local machine and I do have Python installed on it. I can call my script via the command line but apparently not via an Ajax Request for no apparent reason. – Toussah Oct 31 '13 at 08:00
  • This doesn't answer my question. Webserve should have python module installed and configured too, to know that files with .py extension are python scripts and how to handle them. By default server send file as is (like .js, .html, .css, etc.). You can see in firebug, that ajax is calling `http://localhost/TestTree3/puthonScripts/test.py`. Call it from your browser and you will probably see that python is not working. – Krzysztof Oct 31 '13 at 09:18
  • I guess it might be the problem indeed since I don't remember configuring anything on my WampServer. Would you have any clue about how configuring it. I'm using Windows (64 bit), Python 2.7 (64 bit) and Apache 2.4 (64 bit too). I've looked it up on google and found out I had to install mod_wsgi, unfortunately there is only an installing guide for 32 bit platform, I tried to use PyPm in vain. – Toussah Oct 31 '13 at 13:51
  • OK it finally works, I changed the httpd.conf file of Apache and now it seems to work. Thank you anyway for helping me pointing out what the problem was. – Toussah Oct 31 '13 at 14:25

0 Answers0