PDA

View Full Version : [FIXED][3.0rev3858] Ext.data.Api throws exception for invalid API



dj
3 May 2009, 6:07 AM
What's the reasoning behind throwing these kind of errors?

Ext.data.Api: recieved an invalid API-configuration "something". Please ensure your proxy API-configuration contains only the actions "create, load, save, destroy


What does it hurt if my API (coming from an ExtDirect.addProvider-call) contains more than the necessary CRUD verbs?

christocracy
3 May 2009, 7:56 AM
Please show me your proxy config.

dj
3 May 2009, 8:13 AM
App.REMOTING_API = {
"type": "remoting",
"namespace": "App.Direct",
"url": "/backend/direct/proxy",
"actions": {
// ...
"Video": [{
"name": "load",
"len": 1
},
{
"name": "play",
"len": 1
},
{
"name": "destroy",
"len": 1
},
{
"name": "create",
"len": 1
},
{
"name": "save",
"len": 2
}],
// ...
"Media": [{
"name": "upload_preview_screen",
"len": 1
},
{
"name": "load",
"len": 1
},
{
"name": "get_for_video",
"len": 1
},
{
"name": "assign_to_video",
"len": 1
},
{
"name": "destroy",
"len": 1
},
{
"name": "create",
"len": 1
},
{
"name": "save",
"len": 2
}]
// ...
}
};
Ext.Direct.addProvider(App.REMOTING_API);



and the proxy e.g.:


//...
proxy: new Ext.data.DirectProxy({
api: App.Direct.Video
}),
//...

christocracy
3 May 2009, 9:20 AM
Right, you're plugging your Direct-object right into the api. The Api validator is too restrictive. I'll fix this so it won't throw exception in this case.

To get around the exception currently, you'd have to do this:


api: {
load : App.Direct.Video.load,
destroy: App.Direct.Video.destroy,
.
.
.
}

dj
3 May 2009, 6:09 PM
Thanks Chris,

right now I'm using this (admittedly greedy) override:


Ext.apply(Ext.data.Api, {
isValid: function(){
return true;
}
});


:)

christocracy
19 May 2009, 9:07 AM
I've disabled throwing an exception for this in SVN.

You can kill your override now.

dj
20 May 2009, 10:31 AM
Thanks, just updated to the newest SVN-Version. Keep up the good work!