Leigh, someone already responded about cflock, but let me tell you how
I handle application settings and CFCs. As the other responder
mentioned, it is not good practice to directly reference Application
variables inside CFCs. In the past, I used to simply do

<cfinclude template="settings.cfm">

inside my Application.cfm. settings.cfm would be a set of Application
variables. I'd wrap the include with a check to see if they already
existed.

Now I create a CFC _specifically_ for getting my settings, which I'll
either store in an ini or xml file. I'll either name that CFC
"Application" or give it the same name as the project. My
application.cfm file will then do

<cfinvoke component="cfcs.settings" method="getSettings"
returnVariable="application.settings">

(Again, I wrap it with a check to see if application.settings already exist.)

Now, my CFCs will have the exact same line in their constructor area.
This means they have the same settings values as my code code outside
of my CFCs, but it also means I don't have to worry about passing in
applivation variables.

On Tue, 13 Jul 2004 01:15:26 -0400, leigh white
<[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
> I've been at a loss as to find information on the best way to handle my application's cfcs and config variables ... and from other threads I've read, I think there's probably a few of you here who can help ...
>
> At present, I configure a whole bunch of settings/structures in the application scope (in application.cfm) just the once for each lifetime of the application.
>
> From what I read in an article I located (sorry I dont have it here) - this was fine to do, and I could read/reference the application scope variables directly through my site without having to lock them (as they are used for read only - there is never any writing). Does this seem fine so far? and if so, also reading/referencing them from within cfcs?
>
> The other issue (the main one!) is that in my application.cfm file, I am creating my cfc objects within the application scope. eg:
>
> application.objTimetable = createObject("component", "#application.components#.timetable") ;
>
> The theory being that they are created once and stored in memory for any page to access/utilise at any time - however my concern is are they multi-thread accessible? what other issues are there??
>
> I dont want to have to create a new instance of an object each time I enter the page (ie request scope) and I dont want to store the object in the session scope either (meaning every user logged in has there own object instance!), so that's where I figured storing in the application scope!
>
> Any help or advice would be extremely appreciated
>
> Thanks
> Leigh
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to