PDA

View Full Version : Store doesn't execute my python script



Toussah
30 Oct 2013, 2:59 AM
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:
46630

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.

Gary Schlosberg
31 Oct 2013, 9:09 PM
Sounds like it's not executing. Check that your permissions and ownership settings allow Ext to execute your python script, and that the first line actually points correctly to your Python installation.

Toussah
1 Nov 2013, 1:20 AM
It appeared my Apache server was simply not configured to deal with python scripts. I only had to modify my httpd.conf file and now it works just fine.