Re: Application Scope Problem
Additionally, you can take a look at this blog post for a better understanding of why you need to "var" a variable. http://www.schierberl.com/cfblog/index.cfm/2008/7/21/Thread-safety-and-the-var-scope--live-example >This little tool can help you find what variables need to be put into >the "var" scope: http://varscoper.riaforge.org/ > > >Thanks, > >Eric Cobb >Certified Macromedia ColdFusion MX 7 Developer >http://www.cfgears.com > > >Paul Alkema wrote: >> ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323745 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Application Scope Problem
This little tool can help you find what variables need to be put into the "var" scope: http://varscoper.riaforge.org/ Thanks, Eric Cobb Certified Macromedia ColdFusion MX 7 Developer http://www.cfgears.com Paul Alkema wrote: > Ok, I'll look into that and see if that fixes the problem. Also don't worry > about the bluntness, heh, I didn't write this code, I just inherited it. :) > > Paul > > -Original Message- > From: Adam Haskell [mailto:a.hask...@gmail.com] > Sent: Friday, June 19, 2009 2:55 PM > To: cf-talk > Subject: Re: Application Scope Problem > > > It has nothing to do with Application scope and everything to do with poorly > written code, sorry to be blunt but that's the issue. As was said all > variables you that you want to be local to that method need to be var'ed. > Currently you are not doing this so those variables are bleeding out of the > method's variable scope (which lives and dies with each call to the method) > and getting into the Object's scope (which lives and dies with the > application since the Object is stored on the Application scope). Again this > is not an issue with putting the object on the Application scope it is an > issue with how the variables are defined in the method. > > Adam > > > On Thu, Jun 18, 2009 at 8:49 AM, Paul Alkema > wrote: > >> Has anyone else experienced this issue before with the application scope? >> So >> if I ripped this out of the application scope you think it the issue I am >> having would be fixed correct? >> >> Also, please explain what you mean by ensuring that the arguments >> parameters >> aren't "sticky"? >> >> Do you mean referencing the scope in the cfargument tag? >> >> Like... >> >> >> Instead of... >> >> >> >> >> Thanks! >> -Original Message- >> From: Jason Fisher [mailto:ja...@wanax.com] >> Sent: Wednesday, June 17, 2009 3:42 PM >> To: cf-talk >> Subject: RE: Application Scope Problem >> >> >> Completely agree with Brad. Also wouldn't hurt to ensure that the >> arguments parameters aren't sticky, by referencing the scope of 'language' >> and 'placeholder' as appropriate. >> >> > hint="Returns the text found for the given language and placeholder"> >> >> >> >> >> >> >> >> >> >> >>SELECT content >>FROM translations >>WHERE lang = > value="#arguments.language#"> >>AND placeholder = > value="#arguments.placeholder#"> >> >> >> >> >>> 'EN') > >> >>SELECT content >>FROM translations >>WHERE lang = 'EN' >>AND placeholder = > value="#arguments.placeholder#"> >> >> >> >> >> >> >> >> >>", >> arguments[varName])> >> >> >> >> >> >> >> >> >> From: b...@bradwood.com >> Sent: Wednesday, June 17, 2009 3:38 PM >> To: "cf-talk" >> Subject: RE: Application Scope Problem >> >> Do you think this could have anything to do with the fact that this >> function >> is being stored in the application scope? >> >> === >> >> Yes, it has everything to do with that. You need to var EVERY variable >> used in that function. Otherwise it is shared by everyone calling your >> code at the exact same time >> >> getTranslation and varName need to be varred like so at the top of the >> function. >> >> ~Brad >> >> >> >> >> >> > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323727 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
Ok, I'll look into that and see if that fixes the problem. Also don't worry about the bluntness, heh, I didn't write this code, I just inherited it. :) Paul -Original Message- From: Adam Haskell [mailto:a.hask...@gmail.com] Sent: Friday, June 19, 2009 2:55 PM To: cf-talk Subject: Re: Application Scope Problem It has nothing to do with Application scope and everything to do with poorly written code, sorry to be blunt but that's the issue. As was said all variables you that you want to be local to that method need to be var'ed. Currently you are not doing this so those variables are bleeding out of the method's variable scope (which lives and dies with each call to the method) and getting into the Object's scope (which lives and dies with the application since the Object is stored on the Application scope). Again this is not an issue with putting the object on the Application scope it is an issue with how the variables are defined in the method. Adam On Thu, Jun 18, 2009 at 8:49 AM, Paul Alkema wrote: > > Has anyone else experienced this issue before with the application scope? > So > if I ripped this out of the application scope you think it the issue I am > having would be fixed correct? > > Also, please explain what you mean by ensuring that the arguments > parameters > aren't "sticky"? > > Do you mean referencing the scope in the cfargument tag? > > Like... > > > Instead of... > > > > > Thanks! > -Original Message----- > From: Jason Fisher [mailto:ja...@wanax.com] > Sent: Wednesday, June 17, 2009 3:42 PM > To: cf-talk > Subject: RE: Application Scope Problem > > > Completely agree with Brad. Also wouldn't hurt to ensure that the > arguments parameters aren't sticky, by referencing the scope of 'language' > and 'placeholder' as appropriate. > > hint="Returns the text found for the given language and placeholder"> > > > > > > > > > > >SELECT content >FROM translations >WHERE lang = value="#arguments.language#"> >AND placeholder = value="#arguments.placeholder#"> > > > > > 'EN') > > >SELECT content >FROM translations >WHERE lang = 'EN' >AND placeholder = value="#arguments.placeholder#"> > > > > > > > > >", > arguments[varName])> > > > > > > > > > From: b...@bradwood.com > Sent: Wednesday, June 17, 2009 3:38 PM > To: "cf-talk" > Subject: RE: Application Scope Problem > > Do you think this could have anything to do with the fact that this > function > is being stored in the application scope? > > === > > Yes, it has everything to do with that. You need to var EVERY variable > used in that function. Otherwise it is shared by everyone calling your > code at the exact same time > > getTranslation and varName need to be varred like so at the top of the > function. > > ~Brad > > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323726 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Application Scope Problem
It has nothing to do with Application scope and everything to do with poorly written code, sorry to be blunt but that's the issue. As was said all variables you that you want to be local to that method need to be var'ed. Currently you are not doing this so those variables are bleeding out of the method's variable scope (which lives and dies with each call to the method) and getting into the Object's scope (which lives and dies with the application since the Object is stored on the Application scope). Again this is not an issue with putting the object on the Application scope it is an issue with how the variables are defined in the method. Adam On Thu, Jun 18, 2009 at 8:49 AM, Paul Alkema wrote: > > Has anyone else experienced this issue before with the application scope? > So > if I ripped this out of the application scope you think it the issue I am > having would be fixed correct? > > Also, please explain what you mean by ensuring that the arguments > parameters > aren't "sticky"? > > Do you mean referencing the scope in the cfargument tag? > > Like... > > > Instead of... > > > > > Thanks! > -Original Message- > From: Jason Fisher [mailto:ja...@wanax.com] > Sent: Wednesday, June 17, 2009 3:42 PM > To: cf-talk > Subject: RE: Application Scope Problem > > > Completely agree with Brad. Also wouldn't hurt to ensure that the > arguments parameters aren't sticky, by referencing the scope of 'language' > and 'placeholder' as appropriate. > > hint="Returns the text found for the given language and placeholder"> > > > > > > > > > > >SELECT content >FROM translations >WHERE lang = value="#arguments.language#"> >AND placeholder = value="#arguments.placeholder#"> > > > > > 'EN') > > >SELECT content >FROM translations >WHERE lang = 'EN' >AND placeholder = value="#arguments.placeholder#"> > > > > > > > > >", > arguments[varName])> > > > > > > > > > From: b...@bradwood.com > Sent: Wednesday, June 17, 2009 3:38 PM > To: "cf-talk" > Subject: RE: Application Scope Problem > > Do you think this could have anything to do with the fact that this > function > is being stored in the application scope? > > === > > Yes, it has everything to do with that. You need to var EVERY variable > used in that function. Otherwise it is shared by everyone calling your > code at the exact same time > > getTranslation and varName need to be varred like so at the top of the > function. > > ~Brad > > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323725 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
Well, it's different than I thought. I think, at one time, we had the component in the application scope, but took it out because of similar errors. Now, the component is only created on the few pages where it is required. Still, we have the intermittant errors. Here is one of the error messages: Could not find the ColdFusion Component or Interface GlobalFunctions. Ensure that the name is correct and that the component or interface exists. The error occurred on line 22. It is called by: It may be an issue with component instantiation because this works 99% of the time, but fails without any explanation. Thanks, Mike -Original Message- From: Adrian Lynch [mailto:cont...@adrianlynch.co.uk] Sent: Thursday, June 18, 2009 8:43 AM To: cf-talk Subject: RE: Application Scope Problem How are you setting the component in the app scope? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323638 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
Sorry Paul, I was talking to Michael. Just wanted to see how it was set because I've had similar errors but I put it down to OnApplicationStart only partially completing because of an error so some init code wasn't reached. Adrian > -Original Message- > From: Paul Alkema [mailto:paulalkemadesi...@gmail.com] > Sent: 18 June 2009 14:53 > To: cf-talk > Subject: RE: Application Scope Problem > > > Code Example > > application.translator=createObject("component",'packages.translator.tr > ansla > tor')> > > > > access="public" > name="lookup" > returntype="string" > output="no" > hint="Returns the text found for the given language and > placeholder"> > > required="yes"> > type="string" > required="yes"> > > > > > SELECT * FROM translations > WHERE lang = value="#language#"> > AND placeholder = value="#placeholder#"> > > > > > > > SELECT * FROM translations > WHERE lang = 'EN' > AND placeholder = value="#placeholder#"> > > > > > > > > > #varName# > %>", arguments[varName])> > > > > > > > > > > #application.translator.lookup(placeholder="testtext.69EE0E03",language > =requ > est.current_lang)# > > > > -Original Message- > From: Adrian Lynch [mailto:cont...@adrianlynch.co.uk] > Sent: Thursday, June 18, 2009 9:43 AM > To: cf-talk > Subject: RE: Application Scope Problem > > > How are you setting the component in the app scope? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323636 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Application Scope Problem
Code Example SELECT * FROM translations WHERE lang = AND placeholder = SELECT * FROM translations WHERE lang = 'EN' AND placeholder = ", arguments[varName])> #application.translator.lookup(placeholder="testtext.69EE0E03",language=requ est.current_lang)# -Original Message- From: Adrian Lynch [mailto:cont...@adrianlynch.co.uk] Sent: Thursday, June 18, 2009 9:43 AM To: cf-talk Subject: RE: Application Scope Problem How are you setting the component in the app scope? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323635 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Application Scope Problem
"Sticky", meaning that a variable holds the same value across multiple calls, because it's in the application scope, and therefore shared across all users of that application. The 'arguments' scope should be used within the body of the function, not the CFARGUMENT tag. So, this is fine: But then in the code, as I showed in my previous post, do this: WHERE language = Instead of ... WHERE language = Between that and using the 'var' flag on the variables that are internal to the function, as Brad noted, you should be in much better shape. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323634 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
How are you setting the component in the app scope? > -Original Message- > From: Dawson, Michael [mailto:m...@evansville.edu] > Sent: 18 June 2009 14:20 > To: cf-talk > Subject: RE: Application Scope Problem > > > We have had instances where a component, stored in the application > scope, could not be found. > > It is weird, because it works 99% of the time. > > Thanks, > Mike ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323633 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
We have had instances where a component, stored in the application scope, could not be found. It is weird, because it works 99% of the time. Thanks, Mike -Original Message- From: Paul Alkema [mailto:paulalkemadesi...@gmail.com] Sent: Thursday, June 18, 2009 7:54 AM To: cf-talk Subject: RE: Application Scope Problem Has anyone else experienced this issue before with the application scope? So if I ripped this out of the application scope you think it the issue I am having would be fixed correct? Also, please explain what you mean by ensuring that the arguments parameters aren't "sticky"? Do you mean referencing the scope in the cfargument tag? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323632 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Application Scope Problem
Has anyone else experienced this issue before with the application scope? So if I ripped this out of the application scope you think it the issue I am having would be fixed correct? Also, please explain what you mean by ensuring that the arguments parameters aren't "sticky"? Do you mean referencing the scope in the cfargument tag? Like... Instead of... Thanks! -Original Message- From: Jason Fisher [mailto:ja...@wanax.com] Sent: Wednesday, June 17, 2009 3:42 PM To: cf-talk Subject: RE: Application Scope Problem Completely agree with Brad. Also wouldn't hurt to ensure that the arguments parameters aren't sticky, by referencing the scope of 'language' and 'placeholder' as appropriate. From: b...@bradwood.com Sent: Wednesday, June 17, 2009 3:38 PM To: "cf-talk" Subject: RE: Application Scope Problem Do you think this could have anything to do with the fact that this function is being stored in the application scope? === Yes, it has everything to do with that. You need to var EVERY variable used in that function. Otherwise it is shared by everyone calling your code at the exact same time getTranslation and varName need to be varred like so at the top of the function. ~Brad ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323630 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
Has anyone else experienced this issue before with the application scope? So if I ripped this out of the application scope you think it the issue I am having would be fixed correct? Also, please explain what you mean by ensuring that the arguments parameters aren't "sticky"? Do you mean referencing the scope in the cfargument tag? Like... Instead of... Thanks! -Original Message- From: Jason Fisher [mailto:ja...@wanax.com] Sent: Wednesday, June 17, 2009 3:42 PM To: cf-talk Subject: RE: Application Scope Problem Completely agree with Brad. Also wouldn't hurt to ensure that the arguments parameters aren't sticky, by referencing the scope of 'language' and 'placeholder' as appropriate. SELECT content FROM translations WHERE lang = AND placeholder = SELECT content FROM translations WHERE lang = 'EN' AND placeholder = ", arguments[varName])> From: b...@bradwood.com Sent: Wednesday, June 17, 2009 3:38 PM To: "cf-talk" Subject: RE: Application Scope Problem Do you think this could have anything to do with the fact that this function is being stored in the application scope? === Yes, it has everything to do with that. You need to var EVERY variable used in that function. Otherwise it is shared by everyone calling your code at the exact same time getTranslation and varName need to be varred like so at the top of the function. ~Brad ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323629 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Application Scope Problem
Completely agree with Brad. Also wouldn't hurt to ensure that the arguments parameters aren't sticky, by referencing the scope of 'language' and 'placeholder' as appropriate. SELECT content FROM translations WHERE lang = AND placeholder = SELECT content FROM translations WHERE lang = 'EN' AND placeholder = ", arguments[varName])> From: b...@bradwood.com Sent: Wednesday, June 17, 2009 3:38 PM To: "cf-talk" Subject: RE: Application Scope Problem Do you think this could have anything to do with the fact that this function is being stored in the application scope? === Yes, it has everything to do with that. You need to var EVERY variable used in that function. Otherwise it is shared by everyone calling your code at the exact same time getTranslation and varName need to be varred like so at the top of the function. ~Brad ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323603 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Application Scope Problem
Do you think this could have anything to do with the fact that this function is being stored in the application scope? === Yes, it has everything to do with that. You need to var EVERY variable used in that function. Otherwise it is shared by everyone calling your code at the exact same time getTranslation and varName need to be varred like so at the top of the function. ~Brad ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323601 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Application scope problem
It's also worth asking if you're doing this on EVERY page load or only on application initilization.. ie... if (not isDefined("application.rews") { // set vars here } ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:261081 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Application scope problem
Matthew Chambers wrote: > > application.rews.timePeriods[1] = StructNew(); You might try using : arrayAppend(application.rews.timePeriods, structNew()); Or... create the struct first... ie tmpStruct = structNew() tmpStruct.xxx = val; tmpStruct.yyy = val; tmpStruct.zzz = val then arrayAppend(application.rews.timePeriods, tmpStruct); ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:261080 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4