-
13 May 2009 6:58 AM #11
Most of the functionality is wrapped inside of Direct.cfm. Initially i had this implemented as a single Application.cfc file which you could drop inside a "service" directory and then it handled all sorts of things such as security etc. However, I thought that this would be too limiting to many users and refactored it into the 3 file structure it is now.
You can customize what is sent down to the client via any application specific logic that you want. This could be a new custom attribute such as a Role like "Administrator", "Moderator", "User" or it could be something more fine grained such as the users userId and a complex set of permissions that are stored in a db/file system/web service call somewhere.
Perhaps this would be best done by allowing users to provide a filter in Direct.cfc getAPIScript immediately before outputting the API spec. What do you think?
EDIT: As I posted above the invokeCall method in the CFC should be checking to make sure that ExtDirect attribute is set on both the CFC and Method.
As another poster mentioned all of your other security constraints should be handled at the server-side just like we've done in the past in a typical Ajax app.Last edited by aconran; 13 May 2009 at 7:01 AM. Reason: added some stuff...
Aaron Conran
@aconran
Sencha Architect Development Team
-
13 May 2009 1:02 PM #12
How about a small grid example. Please. Is CFQueryReader.js no longer needed to return json from a cfquery cfc ?
-
14 May 2009 1:45 PM #13
Direct & CFQueryReader
Direct & CFQueryReader
@Jvrozier - I'll be looking at that this weekend, since I just put out a new version of the CFQueryReader. Haven't had a chance to look at all of this in depth yet, but I did see a mention of SerializeJSON(), which would mean your CF methods weren't portable, allowing you to use them throughout your application (direct method call within a cfm or other cfc, for instance).
--
Steve "Cutter" Blades
Adobe Community Professional - ColdFusion
Adobe Certified Professional - Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
Blog: Cutter's Crossing
Co-Author "Learning Ext JS 3.2"
-
15 May 2009 7:24 AM #14
DirectCFM + CFQueryReader
DirectCFM + CFQueryReader
I've completely read through Aaron's code, and stepped through the processes laid out by each of the individual templates.
I'm not sure how I feel about the way the API is constructed, and feel it may be better to use a different method of constructing the descriptor. Something akin to how you might do it with ColdSpring I think would work better. Since this would be run on a page request, it would be nice to have the data in some type of persistent scope, so that you're only looping your file structure once on application or session startup. I'm also not sure about a .cfm being used as the router. I guess that could be changed, as it is a config option within your Direct.cfc. All of this is another discussion.
Direct is used for pushing data to, and getting data from, the server. Aaron's script is automatically serializing the ColdFusion struct into a JSON object, so you wouldn't need to utilize the returnFormat: 'JSON' attribute any longer within your baseParams. For reading queries into a Store, you would need to use the latest version of CFQueryReader v1.1, as you would need the ability to set your 'root' attribute for the location of any CF Query return object, which isn't part of the original CFQueryReader.--
Steve "Cutter" Blades
Adobe Community Professional - ColdFusion
Adobe Certified Professional - Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
Blog: Cutter's Crossing
Co-Author "Learning Ext JS 3.2"
-
18 May 2009 6:28 AM #15
Glad to see some people looking through the code!

This is simply meant to be a reference implementation demonstrating to ColdFusion developers how they can integrate it into their own environments. It is simple on purpose.
This is how I initially implemented it and cached it in the application scope. (This code actually goes a couple years back and was originally used in CFMX 6.1 w/ the CFJSON project.) One thing you need to be aware of when caching your API is that an application cache provider will not work for all environments. For example say you have user/role based security then a session provider cache would probably be a better implementation.
Tommy has a good approach for this in his Altenative PHP Direct Stack that allows you to implement CacheProviders. I'd love to see someone take the DirectCFM and run with it!Aaron Conran
@aconran
Sencha Architect Development Team
-
18 May 2009 6:35 AM #16
Direct
Direct
Yeah, that's kind of where I thought you (Ext) was going with these server-side stacks. That's the same comment I made a few minutes ago here:
http://www.sporcic.org/2009/05/extdirect-miss/
I hope to get some time to look a bit closer in the future, but I do have a new project I'm working on
--
Steve "Cutter" Blades
Adobe Community Professional - ColdFusion
Adobe Certified Professional - Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
Blog: Cutter's Crossing
Co-Author "Learning Ext JS 3.2"
-
27 May 2009 7:44 PM #17
Direct + CFQueryReader
Direct + CFQueryReader
Hopefully Aaron is watching this thread, and maybe could speak to what I'm seeing.
I successfully setup the API and Router config, and was able to make a request. I then tried to setup a DirectStore using the CFQueryReader.
When running the code, I see that the request is made of the Router, and gets a valid response array.Code:var provider = Ext.Direct.addProvider(com.cc.APIDesc); // This is the Field Definition to be used by the CFQueryReader of each Store var fieldDef = [ {name:'city', type:'string'}, {name:'state', type:'string'}, {name:'zip', mapping:'postalcode', type:'string'}, {name:'email', type:'string'}, {name:'phone', type:'string'}, {name:'fax',type:'string'}, {name:'thepassword',type:'string'}, {name:'artistId', type:'int'}, {name:'firstName', type:'string'}, {name:'lastName', type:'string'}, {name:'address', type:'string'} ]; var sds = new Ext.data.DirectStore({ storeId: 'Standard', directFn:com.cc.testProxy.getAllStandard, reader: new Ext.data.CFQueryReader({ id:'artistId', root:'result' },fieldDef) }); sds.load();
What I don't see is the response ever being passed to the custom DataReader. I thought that it was because the response object was an array, but when I tried to place a console.log statement on the read() method of the custom reader, the object never appeared to be passed in to the custom reader at all.Code:[{"method":"getAllStandard","tid":2.0,"action":"testProxy","type":"rpc","result":{"COLUMNS":["ARTISTID" ,"FIRSTNAME","LASTNAME","ADDRESS","CITY","STATE","POSTALCODE","EMAIL","PHONE","FAX","THEPASSWORD"],"DATA" :[[1,"Aiden","Donolan","352 Corporate Ave.","Denver","CO","80206-4526","aiden.donolan@donolan.com","555-751-8464" ,"555-751-8463","peapod"],[2,"Austin","Weber","25463 Main Street, Suite C","Berkeley","CA","94707-4513" ,"austin@life.com","555-513-4318","510-513-4888","nopolyes"],[3,"Elicia","Kim","2523 National Blvd","Los Angeles","CA","90064-5134","eleciakim@newmedia.com","555-846-4613","","longtail"],[4,"Jeff","Baclawski" ,"903 Boardwalk Ave","Hollywood","FL","33021-8894","user@demodata.com","239-213-4561","239-213-7465" ,"demo"],[5,"Lori","Johnson","6462 Cowtown Rd","Pierre","SD","57501-7782","lb@bovinas.com","605-776-8461" ,"605-776-8462","nowhere"],[6,"Maxwell","Wilson","72500 MLK Blvd","Tulsa","OK","74116-4613","max@mypaintings .com","918-347-4513","918-456-1315","eyeball"],[7,"Paul","Trani","3320 Fashion Dr","New York","NY","10017-1231" ,"paul.trani@trani.com","212-630-5345",null,"ouchy"],[8,"Raquel","Young","1120 Presidential Ave","Atlanta" ,"GA","39901-4813","raquel@soulpaints.com","770-397-9486","770-391-8435","cmyk"],[9,"Viata","Trenton" ,"4563 42nd St","New York","NY","10012-4562","trenton.v@trenton.com","212-456-8468","212-468-8765","pillow" ],[10,"Diane","Demo","123 Demo Lane","Denver","CO",55555.0,"diane@demo.com","555-555-5555","","demo" ],[11,"Anthony","Kunovic","111 94th Ave","Aspen","CO",90809.0,"aj@ajgalleries.com","970-555-1373",null ,"overlord"],[12,"Ellery","Buntel","23 Elm St","Washington","DC",77893.0,"ellery.buntel@myart.com","637-902-7200" ,"637-300-2888","crayon"],[13,"Emma","Buntel","789 Main St","Washington","DC",77834.0,"emma.buntel@myart .com","637-930-2999",null,"bluebird"],[14,"Taylor Webb","Frazier","58 Plaza Ct","Santa Fe","NM",34453 .0,"taylor.webb@myart.com","444-333-9876",null,"icecream"],[15,"Mike","Nimer","qwed qdsa","asd da","ca" ,1321.0,"me@m.com",null,null,"admin"]]}}]
Any ideas? I am using the latest (v1.1) version of CFQueryReader, which works fine under a normal Ext.data.Store with Ext 3.0. I'm fighting Direct right now.--
Steve "Cutter" Blades
Adobe Community Professional - ColdFusion
Adobe Certified Professional - Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
Blog: Cutter's Crossing
Co-Author "Learning Ext JS 3.2"
-
27 May 2009 8:15 PM #18
Hi Steve, just fyi, I successfully setup DirectCFM with your CFQueryReader 1.1 without any issues.. here my config:
I think you missed the paramsAsHash config..Code:store: new Ext.data.DirectStore({ autoLoad: true, storeId: 'Standard', directFn: Ext.ss.Data.load, paramsAsHash: false, reader: new Ext.data.CFQueryReader({ id:'uid', root:'records' }, [ {name: 'uid', type: 'int'}, {name: 'display_name', type: 'string'} ] ) })
-
28 May 2009 2:27 AM #19
CFQueryReader + Direct
CFQueryReader + Direct
@kanntronics
Sweet! I didn't think that the paramsAsHash attribute was required. Dropped it in and away we go
And please, call me Cutter. Only my mom calls me Steve
--
Steve "Cutter" Blades
Adobe Community Professional - ColdFusion
Adobe Certified Professional - Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
Blog: Cutter's Crossing
Co-Author "Learning Ext JS 3.2"
-
28 May 2009 2:32 AM #20
Custom Namespaces
Custom Namespaces
Small error I found yesterday within Direct.cfc. If you define a custom namespace within Api.cfc, you expect to get that namespace for use. Within Direct.cfc, in the getAPIScript() method, you'll need to adjust line 65 from:
to read:Code:<cfset jsonPacket['namespace'] = "Ext.ss" />
Code:<cfset jsonPacket['namespace'] = ARGUMENTS.ns />
--
Steve "Cutter" Blades
Adobe Community Professional - ColdFusion
Adobe Certified Professional - Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
Blog: Cutter's Crossing
Co-Author "Learning Ext JS 3.2"



Reply With Quote