Re: Instantiating all objects within Application.cfm
Heh, I've never tried that - I knew that the unnamed application scope allowed for integration with servlets, but I've never actually dumped it. On 9/23/07, Sean Corfield [EMAIL PROTECTED] wrote: On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: So was I - as long as I know the application name, a CFAPPLICATION tag anywhere on the machine can make any CF code part of your application. There is no folder restriction on this and no way to prevent it. Just set your application name to the empty string and you can see *everyone's* application scopes by dumping yours. That's just how the underlying Java Servlet context works -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289210 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
Wow, I had no idea that was the case. So basically, never, ever host anything sensitive on a shared server. On 9/22/07, Sean Corfield [EMAIL PROTECTED] wrote: On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: So was I - as long as I know the application name, a CFAPPLICATION tag anywhere on the machine can make any CF code part of your application. There is no folder restriction on this and no way to prevent it. Just set your application name to the empty string and you can see *everyone's* application scopes by dumping yours. That's just how the underlying Java Servlet context works. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood ~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289244 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Instantiating all objects within Application.cfm
Wow, I had no idea that was the case. So basically, never, ever host anything sensitive on a shared server. That has always been the case. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289246 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
Sorry, that's just completely wrong. Any page, anywhere on the server, can use your Application name and get your Application scope variables; this can't even be prevented with sandboxing. If I have access to createObject(java) (which can be sandboxed out), I can even use the service factory to get your application name (and the app names for everyone else) and get everything in your application (and for that matter your sessions too). In fact I have a session tracker for monitoring purposes on our servers that relies on this ability. On 9/21/07, Brian Kotek wrote: They can't, and I'm 99% sure they never have been. The only code that can read an application variable is code that lives under a directory where the cfapplication tag with that application name. Many people store this info in an application-scoped Config CFC and pass that into whatever other CFCs need it. On 9/21/07, Andrew Grosset wrote: I use the request scope for database name, username password for cfqueries since I believe application variables can be read by all on a shared server - not sure if this is still the case though. -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289181 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
Yes but guessing the application name is not easy... On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: Sorry, that's just completely wrong. Any page, anywhere on the server, can use your Application name and get your Application scope variables; this can't even be prevented with sandboxing. If I have access to createObject(java) (which can be sandboxed out), I can even use the service factory to get your application name (and the app names for everyone else) and get everything in your application (and for that matter your sessions too). In fact I have a session tracker for monitoring purposes on our servers that relies on this ability. On 9/21/07, Brian Kotek wrote: They can't, and I'm 99% sure they never have been. The only code that can read an application variable is code that lives under a directory where the cfapplication tag with that application name. Many people store this info in an application-scoped Config CFC and pass that into whatever other CFCs need it. On 9/21/07, Andrew Grosset wrote: I use the request scope for database name, username password for cfqueries since I believe application variables can be read by all on a shared server - not sure if this is still the case though. -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289182 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
If in doubt I can get all the app names from the application tracker factory object and get everything from all of them. On 9/22/07, Andrew Scott wrote: Yes but guessing the application name is not easy... -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289183 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
not in cf8 you can't if it has been sandboxed right. On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: If in doubt I can get all the app names from the application tracker factory object and get everything from all of them. On 9/22/07, Andrew Scott wrote: Yes but guessing the application name is not easy... -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289195 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
I was talking about in CF code. Of course if the instance of CF isn't secured or is older then you can get at absolutely anything with the underlying Java objects. Basically, don't host anything sensitive on an unsecured, shared server. I assumed this was a well known rule, but maybe I was wrong. On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: Sorry, that's just completely wrong. Any page, anywhere on the server, can use your Application name and get your Application scope variables; this can't even be prevented with sandboxing. If I have access to createObject(java) (which can be sandboxed out), I can even use the service factory to get your application name (and the app names for everyone else) and get everything in your application (and for that matter your sessions too). In fact I have a session tracker for monitoring purposes on our servers that relies on this ability. ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289199 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
So was I - as long as I know the application name, a CFAPPLICATION tag anywhere on the machine can make any CF code part of your application. There is no folder restriction on this and no way to prevent it. On 9/22/07, Brian Kotek [EMAIL PROTECTED] wrote: I was talking about in CF code. Of course if the instance of CF isn't secured or is older then you can get at absolutely anything with the underlying Java objects. Basically, don't host anything sensitive on an unsecured, shared server. I assumed this was a well known rule, but maybe I was wrong. On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: Sorry, that's just completely wrong. Any page, anywhere on the server, can use your Application name and get your Application scope variables; this can't even be prevented with sandboxing. If I have access to createObject(java) (which can be sandboxed out), I can even use the service factory to get your application name (and the app names for everyone else) and get everything in your application (and for that matter your sessions too). In fact I have a session tracker for monitoring purposes on our servers that relies on this ability. ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289204 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
On 9/22/07, James Holmes [EMAIL PROTECTED] wrote: So was I - as long as I know the application name, a CFAPPLICATION tag anywhere on the machine can make any CF code part of your application. There is no folder restriction on this and no way to prevent it. Just set your application name to the empty string and you can see *everyone's* application scopes by dumping yours. That's just how the underlying Java Servlet context works. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289208 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
They can't, and I'm 99% sure they never have been. The only code that can read an application variable is code that lives under a directory where the cfapplication tag with that application name. Many people store this info in an application-scoped Config CFC and pass that into whatever other CFCs need it. On 9/21/07, Andrew Grosset [EMAIL PROTECTED] wrote: I use the request scope for database name, username password for cfqueries since I believe application variables can be read by all on a shared server - not sure if this is still the case though. Andrew. I store settings such as the applications database name in the application scope since it is global to all requests and does not change for the app. ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289090 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
This will return an array of the names of all applications running on a server .are untested and potentially dangerous (especially in shared hosting environments) - but can be very useful for developers or securely managing your applications on a dedicated box http://www.lynchconsulting.com.au/blog/index.cfm/2006/10/23/Hacking-the-application-scope-in-CFMX I haven't tested this in a shared hosting environment but it has legitimate uses never the less Andrew. They can't, and I'm 99% sure they never have been. The only code that can read an application variable is code that lives under a directory where the cfapplication tag with that application name. Many people store this info in an application-scoped Config CFC and pass that into whatever other CFCs need it. ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289174 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
Well, you're creating the CFCs over and over on every single request, which is probably not good. Depending on what the CFCs do, and whether they are stateless (have no changing instance data) or stateful (holds changing instance data, or holds different instance data for each user), most people store stateless instances in the application scope so they are only created once during the lifetime of the application. Stateful CFC are harder to store in the application scope since concurrency must be dealt with, and per-request CFCs (CFCs that are unique to each user or to each request) can't be easily kept in the application scope, and must be created for each request or possibly stored in the session scope. On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: While building my first app using CFCs yesterday, I found it easier for me to do a test for the existence of an object and if not found, instantiate it within Application.cfm like this. cfif NOT isDefined(request.dsn) cfset request.dsn = mydatabase / /cfif cfif NOT isDefined(request.inventory) cfset request.inventory = createObject(component, cfcs.inventory).init(request.dsn) / /cfif cfif NOT isDefined(request.classes) cfset request.classes = createObject(component, cfcs.classes).init(request.dsn) / /cfif ... /application.cfm Each instantiation is calling a simple init() method within the class such as this one within inventory.cfc: cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction (there are more methods within this cfc but I'm leaving them out to make this easier to read.) /cfcomponent My thought here is that I will always have access to the instantiated objects without having to test for their existence. However, since I'm not completely familiar with how this all works, Am I creating large amounts of overhead to the server for this convenience? I wouldn't think so since I'm not calling any major methods yet but maybe there is more going on? ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288898 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
Thanks Brian I failed to mention that these are my database cfcs which will often change so application scope isn't the best choice for me. Even though I'm not actually calling a database CRUD method yet, I wanted a handle on the objects to grab later down in the page build. It's a small application but every page request will be returning dynamic data. Is there a lot more overhead instantiating an object versus say cfparam name=blah default= ? Brian Kotek wrote: Well, you're creating the CFCs over and over on every single request, which is probably not good. Depending on what the CFCs do, and whether they are stateless (have no changing instance data) or stateful (holds changing instance data, or holds different instance data for each user), most people store stateless instances in the application scope so they are only created once during the lifetime of the application. Stateful CFC are harder to store in the application scope since concurrency must be dealt with, and per-request CFCs (CFCs that are unique to each user or to each request) can't be easily kept in the application scope, and must be created for each request or possibly stored in the session scope. On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: While building my first app using CFCs yesterday, I found it easier for me to do a test for the existence of an object and if not found, instantiate it within Application.cfm like this. cfif NOT isDefined(request.dsn) cfset request.dsn = mydatabase / /cfif cfif NOT isDefined(request.inventory) cfset request.inventory = createObject(component, cfcs.inventory).init(request.dsn) / /cfif cfif NOT isDefined(request.classes) cfset request.classes = createObject(component, cfcs.classes).init(request.dsn) / /cfif ... /application.cfm Each instantiation is calling a simple init() method within the class such as this one within inventory.cfc: cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction (there are more methods within this cfc but I'm leaving them out to make this easier to read.) /cfcomponent My thought here is that I will always have access to the instantiated objects without having to test for their existence. However, since I'm not completely familiar with how this all works, Am I creating large amounts of overhead to the server for this convenience? I wouldn't think so since I'm not calling any major methods yet but maybe there is more going on? ~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288902 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
You could store them in the session scope. If you use the application.cfcyou could do it all on the onSessionStart method -- Gary Gilbert http://www.garyrgilbert.com/blog ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288915 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Instantiating all objects within Application.cfm
Being that you have stored them in the request scope, the CFIFs are pointless since the request scope is NOT persistent. I store settings such as the applications database name in the application scope since it is global to all requests and does not change for the app. I also store CFCs in the application scope. ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Vince Collins [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 9:12 AM To: CF-Talk Subject: Instantiating all objects within Application.cfm While building my first app using CFCs yesterday, I found it easier for me to do a test for the existence of an object and if not found, instantiate it within Application.cfm like this. cfif NOT isDefined(request.dsn) cfset request.dsn = mydatabase / /cfif cfif NOT isDefined(request.inventory) cfset request.inventory = createObject(component, cfcs.inventory).init(request.dsn) / /cfif cfif NOT isDefined(request.classes) cfset request.classes = createObject(component, cfcs.classes).init(request.dsn) / /cfif ... /application.cfm Each instantiation is calling a simple init() method within the class such as this one within inventory.cfc: cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction (there are more methods within this cfc but I'm leaving them out to make this easier to read.) /cfcomponent My thought here is that I will always have access to the instantiated objects without having to test for their existence. However, since I'm not completely familiar with how this all works, Am I creating large amounts of overhead to the server for this convenience? I wouldn't think so since I'm not calling any major methods yet but maybe there is more going on? ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288918 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: cfif NOT isDefined(request.dsn) cfset request.dsn = mydatabase / /cfif Vince, request.dsn will *NEVER* be defined when the application.cfm is executed, because the Application.cfm is executed at the beginning of the request. So unless you've already created it prior to executing the above code, there's absolutely no need for the cfif statement, because it will always evaluate to true. -- Rick Root Check out CFMBB, BlogCFM, ImageCFC, ImapCFC, CFFM, and more at www.opensourcecf.com ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288930 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
Vince, Requests only last as long as the request, so they will be fully instantiated each and every time regardless of a check to see if they exist or not. Secondly I read that your DB constantly changes, then I sugest you look at reactor and transfer and see how they handle it. The reason being is that in production you DO NOT want to keep reinstantiating, so your code should be relfecting changes as needed and test in that manner, now and not later. On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: While building my first app using CFCs yesterday, I found it easier for me to do a test for the existence of an object and if not found, instantiate it within Application.cfm like this. cfif NOT isDefined(request.dsn) cfset request.dsn = mydatabase / /cfif cfif NOT isDefined(request.inventory) cfset request.inventory = createObject(component, cfcs.inventory).init(request.dsn) / /cfif cfif NOT isDefined(request.classes) cfset request.classes = createObject(component, cfcs.classes).init(request.dsn) / /cfif ... /application.cfm Each instantiation is calling a simple init() method within the class such as this one within inventory.cfc: cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction (there are more methods within this cfc but I'm leaving them out to make this easier to read.) /cfcomponent My thought here is that I will always have access to the instantiated objects without having to test for their existence. However, since I'm not completely familiar with how this all works, Am I creating large amounts of overhead to the server for this convenience? I wouldn't think so since I'm not calling any major methods yet but maybe there is more going on? ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288927 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: Thanks Brian I failed to mention that these are my database cfcs which will often change so application scope isn't the best choice for me. When you say they will often change, what do you mean? You're changing the SQL or column names? Even though I'm not actually calling a database CRUD method yet, I wanted a handle on the objects to grab later down in the page build. It's a small application but every page request will be returning dynamic data. I just want to be sure you're not doing this unnecessarily. You can store the CFC in the application scope and every call to it can return different database results. In fact, this is how almost every database-related CFC works. Is there a lot more overhead instantiating an object versus say cfparam name=blah default= ? Actually, because cfparam evaluates what you have in the default attribute regardless of whether the value exists or not, cfparam would probably perform much more badly. I think cfparam should really be avoided as much as possible for this reason. Brian Kotek wrote: Well, you're creating the CFCs over and over on every single request, which is probably not good. Depending on what the CFCs do, and whether they are stateless (have no changing instance data) or stateful (holds changing instance data, or holds different instance data for each user), most people store stateless instances in the application scope so they are only created once during the lifetime of the application. Stateful CFC are harder to store in the application scope since concurrency must be dealt with, and per-request CFCs (CFCs that are unique to each user or to each request) can't be easily kept in the application scope, and must be created for each request or possibly stored in the session scope. ~| Get involved in the latest ColdFusion discussions, product development sharing, and articles on the Adobe Labs wiki. http://labs/adobe.com/wiki/index.php/ColdFusion_8 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288931 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
Yeah Bobby and Rick, that was just stupid of me wasn't it? :) Each of these were originally placed right before I was going to use the object in their various pages and then I bulk moved them up to Application.cfm without removing the cfif tests. That said, let me remove the offending code so we can get back to the central question. (in application.cfm) cfset request.dsn = mydatabase / cfset request.inventory = createObject(component, cfcs.inventory).init(request.dsn) / cfset request.classes = createObject(component, cfcs.classes).init(request.dsn) / ... /application.cfm Each instantiation is calling a simple init() method within the class such as this one within inventory.cfc: cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate inventory cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction (there are more methods within this cfc but I'm leaving them out to make this easier to read.) /cfcomponent My question is that since these objects are dynamic data (change often), is it OK to just instantiate the objects even if I may not call one of them an that particular page request? Is instantiating an object that simply calls an init() method (as seen above) any more costly than say a cfparam name=blah default=? Or, am I just going down a path I probably shouldn't and just test EVERY single time if I need to instantiate an object when I want to call a method of that object? ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288937 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
The data within the database changes, not the schema per se, however I do want to pass sorts and filters to these queries. application vs request is unclear now to me. If I allow them to filter the query or sort it, I thought it should be scoped to request. No? Sorry if I sound inane here. v Brian Kotek wrote: On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: Thanks Brian I failed to mention that these are my database cfcs which will often change so application scope isn't the best choice for me. When you say they will often change, what do you mean? You're changing the SQL or column names? Even though I'm not actually calling a database CRUD method yet, I wanted a handle on the objects to grab later down in the page build. It's a small application but every page request will be returning dynamic data. I just want to be sure you're not doing this unnecessarily. You can store the CFC in the application scope and every call to it can return different database results. In fact, this is how almost every database-related CFC works. Is there a lot more overhead instantiating an object versus say cfparam name=blah default= ? Actually, because cfparam evaluates what you have in the default attribute regardless of whether the value exists or not, cfparam would probably perform much more badly. I think cfparam should really be avoided as much as possible for this reason. Brian Kotek wrote: Well, you're creating the CFCs over and over on every single request, which is probably not good. Depending on what the CFCs do, and whether they are stateless (have no changing instance data) or stateful (holds changing instance data, or holds different instance data for each user), most people store stateless instances in the application scope so they are only created once during the lifetime of the application. Stateful CFC are harder to store in the application scope since concurrency must be dealt with, and per-request CFCs (CFCs that are unique to each user or to each request) can't be easily kept in the application scope, and must be created for each request or possibly stored in the session scope. ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288939 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
Vince, You don't want to be reinstantiating those objects into the request scope on every request. The data may change often, but the CODE to retrieve that data isn't going to change *THAT* often, is it? What you'd want to do is something like this: cfset request.dsn = mydatabase / cfif not isDefined(application.init) or isDefined(url.reinit) cfset application.inventory = createObject(component, cfcs.inventory).init(request.dsn) / cfset application.classes = createObject(component, cfcs.classes).init(request.dsn) / cfset application.init = true /cfif If your objects are holding data, for example, a list of inventory items.. you just have to make sure that whenever you ADD or UPDATE or DELETE inventory, then you also update the data that the object itself is holding Rick ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288947 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: The data within the database changes, not the schema per se, however I do want to pass sorts and filters to these queries. application vs request is unclear now to me. If I allow them to filter the query or sort it, I thought it should be scoped to request. No? If you're storing the full inventory in the CFC, then you'd have a filter method that would perform a query of queries and return the filtered or sorted data, but not actually modify the internal data within the CFC. But if you have a lot of inventory, you probably don't want to store the inventory in the CFC because the database does a much better job of filtering and sorting data than Coldfusion does. -- Rick Root Check out CFMBB, BlogCFM, ImageCFC, ImapCFC, CFFM, and more at www.opensourcecf.com ~| Check out the new features and enhancements in the latest product release - download the What's New PDF now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288950 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
On Thursday 20 Sep 2007, [EMAIL PROTECTED] wrote: The data within the database changes, not the schema per se, however I do want to pass sorts and filters to these queries. Right, so your method takes the sort/filter arguments, and returns query (or table, or what have you). application vs request is unclear now to me. If I allow them to filter the query or sort it, I thought it should be scoped to request. No? Nope. The *result* should be. -- Tom Chiverton Helping to synergistically scale professional e-tailers on: http://thefalken.livejournal.com This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at St James's Court Brown Street Manchester M2 2JF. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law Society. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 8008. For more information about Halliwells LLP visit www.halliwells.com. ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288948 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
On Thursday 20 Sep 2007, [EMAIL PROTECTED] wrote: (there are more methods within this cfc but I'm leaving them out to make this easier to read.) /cfcomponent Assuming your methods return data, not modify internal state, this CFC is a great candidate to go in application or session scope (via. Application.cfc's onNStart() ). probably shouldn't and just test EVERY single time if I need to instantiate an object when I want to call a method of that object? You'll take a performance hit that you needn't. Be aware, that if you have frames, you can have multiple requests for a given client running at once, and lock/var your functions as needed. -- Tom Chiverton Helping to biannually seize total m-commerce on: http://thefalken.livejournal.com This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at St James's Court Brown Street Manchester M2 2JF. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law Society. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 8008. For more information about Halliwells LLP visit www.halliwells.com. ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288944 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
So Rick, because it's scoped to application, if a user calls something like application.inventory.addInventory() to add a new record, at the end of the addInventory() method, I would just need to what? Do something like this? cfset application.inventory = createObject(component, cfcs.inventory).init(request.dsn) / Rick Root wrote: If your objects are holding data, for example, a list of inventory items.. you just have to make sure that whenever you ADD or UPDATE or DELETE inventory, then you also update the data that the object itself is holding Rick ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288965 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Instantiating all objects within Application.cfm
The data in the database changes of course but that's not what you are storing in the application scope... you are storing the component Eg... cfif not isdefined('application.inventory') cfset application.inventory = createObject(component, cfcs.inventory).init(request.dsn) / (and any other components you need to store) /cfif Then from now on.. cfset myResults = application.inventory.myMethod(myArguments) / cfdump var=#myResults# / ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Vince Collins [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 11:21 AM To: CF-Talk Subject: Re: Instantiating all objects within Application.cfm The data within the database changes, not the schema per se, however I do want to pass sorts and filters to these queries. application vs request is unclear now to me. If I allow them to filter the query or sort it, I thought it should be scoped to request. No? Sorry if I sound inane here. v Brian Kotek wrote: On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: Thanks Brian I failed to mention that these are my database cfcs which will often change so application scope isn't the best choice for me. When you say they will often change, what do you mean? You're changing the SQL or column names? Even though I'm not actually calling a database CRUD method yet, I wanted a handle on the objects to grab later down in the page build. It's a small application but every page request will be returning dynamic data. I just want to be sure you're not doing this unnecessarily. You can store the CFC in the application scope and every call to it can return different database results. In fact, this is how almost every database-related CFC works. Is there a lot more overhead instantiating an object versus say cfparam name=blah default= ? Actually, because cfparam evaluates what you have in the default attribute regardless of whether the value exists or not, cfparam would probably perform much more badly. I think cfparam should really be avoided as much as possible for this reason. Brian Kotek wrote: Well, you're creating the CFCs over and over on every single request, which is probably not good. Depending on what the CFCs do, and whether they are stateless (have no changing instance data) or stateful (holds changing instance data, or holds different instance data for each user), most people store stateless instances in the application scope so they are only created once during the lifetime of the application. Stateful CFC are harder to store in the application scope since concurrency must be dealt with, and per-request CFCs (CFCs that are unique to each user or to each request) can't be easily kept in the application scope, and must be created for each request or possibly stored in the session scope. ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288964 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: So Rick, because it's scoped to application, if a user calls something like application.inventory.addInventory() to add a new record, at the end of the addInventory() method, I would just need to what? Do something like this? cfset application.inventory = createObject(component, cfcs.inventory).init(request.dsn) / No you wouldn't reinit. You might do this... cffunction name=addInventory cfargument ... cfquery ... insert into inventory ... /cfquery cfset this.inventory = this.updateInventoryList() cfreturn /cffunction cffunction name=updateInventoryList hint=updates the locally stored version of the inventory cfquery name=qry select * from inventory /cfquery cfset this.inventory = qry /cffunction Any function that modified the inventory in the database would call the updateInventoryList() method. -- Rick Root Check out CFMBB, BlogCFM, ImageCFC, ImapCFC, CFFM, and more at www.opensourcecf.com ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288976 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
If addInventory() just inserts something into the database, and you aren't storing the entire query result set in the Inventory object as instance data, then you don't need to do anything else. This is all getting rather murky because you haven't actually stated what these components are doing. So answering your questions is difficult because the answers depend on the specific context of what you're trying to do. If you can provide more detail, the answers will become more definite. On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: So Rick, because it's scoped to application, if a user calls something like application.inventory.addInventory() to add a new record, at the end of the addInventory() method, I would just need to what? Do something like this? cfset application.inventory = createObject(component, cfcs.inventory ).init(request.dsn) / Rick Root wrote: If your objects are holding data, for example, a list of inventory items.. you just have to make sure that whenever you ADD or UPDATE or DELETE inventory, then you also update the data that the object itself is holding Rick ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288977 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
It appears, since I am brand new to cfcs, that I didn't know enough yet to ask the right questions so here it goes. = APPLICATION.CFM == !--- Set Global DSN --- cfset request.dsn = mydatabase / !--- Instantiate Inventory Objects --- cfif not isDefined(application.init) or isDefined(url.reinit) cfset application.inventory = createObject(component,cfcs.inventory).init(request.dsn) / cfset application.init = true /cfif INVENTORY.CFM = cfsilent cfparam name=selSortBy default=Name cfparam name=selInventoryID default=0 cfparam name=selClass_Name default= cfparam name=selSubClass_Name default= cfparam name=selSize default= cfparam name=selStartRow default=1 cfparam name=selMaxRows default=75 cfset qryInventory = application.inventory.getInventory('#selSortBy#','#selInventoryID#','#selClass_Name#','#selSubClass_Name#','#selSize#') / /cfsilent == INVENTORY.CFC == cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction !--- getInventory - List inventory method --- cffunction name=getInventory returntype=query access=public HINT=Returns all inventory as 'qryInventory', can pass optionally selSortBy to sort query cfargument name=selSortBy required=false type=string default=Class, Class_Name / cfargument name=selInventoryID required=false type=numeric default=0 / cfargument name=selClass_Name required=false type=string default= / cfargument name=selSubClass_Name required=false type=string default= / cfargument name=selSize required=false type=string default= / cfquery name=qryInventory datasource=#variables.dsn# SELECT InventoryID, Class, Class_Name, SubClass_Code, SubClass_Name, Brand, Name, [Size], Regular_Whse_Case, Whse_Case, Whse_Bottle, Regular_Store_Bottle, Store_Bottle, Broker_Name, Broker_Phone FROM Inventory WHERE Class_Name is not null cfif arguments.selInventoryID neq 0 and InventoryID = cfqueryparam cfsqltype=CF_SQL_INTEGER value=#arguments.selInventoryID# / /cfif cfif arguments.selClass_Name neq and Class_Name = cfqueryparam cfsqltype=CF_SQL_VARCHAR value=#arguments.selClass_Name# / /cfif cfif arguments.selSubClass_Name neq and SubClass_Name = cfqueryparam cfsqltype=CF_SQL_VARCHAR value=#arguments.selSubClass_Name# / /cfif cfif arguments.selSize neq and Size like cfqueryparam cfsqltype=CF_SQL_VARCHAR value=%#arguments.selSize#% / /cfif Order by !--- Filter SQL Injection --- cfelseif arguments.selSortBy eq Class Class cfelseif arguments.selSortBy eq Class Desc Class Desc cfelseif arguments.selSortBy eq Class, SubClass_Name Class, SubClass_Name cfelseif arguments.selSortBy eq Class Desc, SubClass_Name Desc Class Desc, SubClass_Name Desc cfelse Class, Class_Name /cfif /cfquery cfreturn qryInventory / /cffunction /cfcomponent I am late to CFCs, which is perfectly obvious. I'm now looking to get it right out of the gate this time so everyone's help thus far is very much appreciated! If I add a new method in inventory.cfc called addInventory(), do I need to worry about resetting/refreshing the query qryInventory which is returned by the method getInventory? If so why and how and if not should I do this differently because there is a better, more optimal way that does require a refresh? Thanks, Vince ~| Check out the new features and enhancements in the latest product release - download the What's New PDF now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288986 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: If I add a new method in inventory.cfc called addInventory(), do I need to worry about resetting/refreshing the query qryInventory which is Well, if you add a new method, you'll have to reinit the app, because once you've loaded the CFC into the application scope, the CFC file itself is not read again. Changing the file doesn't take affect until the object is recreated. So, if you modify the code in the CFC *AFTER* the application has been initialized, then you have to reinit... in the code that I gave you, you do that by passing ?reinit=1 to the URL of your index page (or reallly any page). This will cause your initialization code in the application.cfm file to fire, which will recreate the object, call the init() method, and that would reload the query data from the database. -- Rick Root Check out CFMBB, BlogCFM, ImageCFC, ImapCFC, CFFM, and more at www.opensourcecf.com ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288993 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Instantiating all objects within Application.cfm
Your inventory CFC does not contain any instance data, and thus would be a good candidate for placing in the application scope. To help you understand the difference, consider the following CFC: cfcomponent cfset variables.myname = / cffunction name=init cfreturn this / /cffunction cffunction name=setName cfargument name=myName / cfset variables.myname = arguments.myname / /cffunction cffunction name=getName cfreturn variables.myname / /cffunction /cfcomponent If this CFC was placed into the application scope, you would run into race conditions. This sequence could happen if this CFC was placed in a shared scope: User A calls setName(Rich), User B calls setName(Vince), User A calls getName() and is returned Vince. Since your CFC does not contain any instance data, it can safely be placed in a shared scope. HTH, Rich ~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289017 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
Thanks to you and others, I understand now that if you change your CFC and have already run it inside the application scope, you need to reinit. Your suggested code is very handy for that. Thanks! Now... This will cause your initialization code in the application.cfm file to fire, which will recreate the object, call the init() method, AND that would reload the query data from the database]. Maybe I'm reading this wrong but that seems to imply, to me, that when you instantiate a cfc-object, all methods are called within that class and if it's a query, it reads that query from the database and into memory and doesn't look at the database again unless you re- instantiate it. To try to prove this to myself, I brought up my browser, loaded the application and displayed the inventory on-screen, then I went into the database and manually added an entry. I then sorted the recordset within the browser and my new entry appeared. This to me means that I wouldn't need to reinit when adding new records. Am I missing something? After I call the method like thus: cfset qryInventory = application.inventory.getInventory('#selSortBy#','#selInventoryID#','#selClass_Name#','#selSubClass_Name#','#selSize#') / I then output it by just referring to the name of the query like this. cfoutput query=qryInventory startrow=#selStartRow# maxrows=#selMaxRows# It seems to me, at least with my CFC's design, that there is no reading of the data into the application memory space, thus no need to reinit unless I change the CFC itself. This behavior is what I would expect but having said that, is there a 'better', way? ~| Check out the new features and enhancements in the latest product release - download the What's New PDF now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289018 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Instantiating all objects within Application.cfm
It seems to me, at least with my CFC's design, that there is no reading of the data into the application memory space, thus no need to reinit unless I change the CFC itself. This behavior is what I would expect but having said that, is there a 'better', way? You are correct. The design that he provided showed a method of caching the results in the CFC's internal memory and a way to refresh that data when changes were made. Rich ~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289036 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Instantiating all objects within Application.cfm
You need to var-scope your queries, or you'll run into concurrency issues if you store this CFC in the application scope. This is critical. You must var-scope everything: query names, loop index variables, temp variables, etc. On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: == INVENTORY.CFC == cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction !--- getInventory - List inventory method --- cffunction name=getInventory returntype=query access=public HINT=Returns all inventory as 'qryInventory', can pass optionally selSortBy to sort query cfargument name=selSortBy required=false type=string default=Class, Class_Name / cfargument name=selInventoryID required=false type=numeric default=0 / cfargument name=selClass_Name required=false type=string default= / cfargument name=selSubClass_Name required=false type=string default= / cfargument name=selSize required=false type=string default= / cfquery name=qryInventory datasource=#variables.dsn# SELECT /cfquery cfreturn qryInventory / /cffunction /cfcomponent ~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289032 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
ack! OK, will do. Thanks! Brian Kotek wrote: You need to var-scope your queries, or you'll run into concurrency issues if you store this CFC in the application scope. This is critical. You must var-scope everything: query names, loop index variables, temp variables, etc. On 9/20/07, Vince Collins [EMAIL PROTECTED] wrote: == INVENTORY.CFC == cfcomponent hint=Inventory Object cfset variables.dsn = / cfset variables.inventory = / cffunction name=init access=public returnType=inventory output=false hint=I instantiate qry cfargument name=dsn type=string required=yes / !--- initiate value(s) --- cfset variables.dsn = arguments.dsn / cfset variables.inventory = none / cfreturn this / /cffunction !--- getInventory - List inventory method --- cffunction name=getInventory returntype=query access=public HINT=Returns all inventory as 'qryInventory', can pass optionally selSortBy to sort query cfargument name=selSortBy required=false type=string default=Class, Class_Name / cfargument name=selInventoryID required=false type=numeric default=0 / cfargument name=selClass_Name required=false type=string default= / cfargument name=selSubClass_Name required=false type=string default= / cfargument name=selSize required=false type=string default= / cfquery name=qryInventory datasource=#variables.dsn# SELECT /cfquery cfreturn qryInventory / /cffunction /cfcomponent ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289044 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Instantiating all objects within Application.cfm
I use the request scope for database name, username password for cfqueries since I believe application variables can be read by all on a shared server - not sure if this is still the case though. Andrew. I store settings such as the applications database name in the application scope since it is global to all requests and does not change for the app. ~| Check out the new features and enhancements in the latest product release - download the What's New PDF now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289061 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4