views:

38

answers:

1

Hello,

I have a CF9 project set up with a multi-tiered directory structure. At the root level I have the live production site with its Application.cfc. It contains a number of variables that are bound to a 'debugMode' flag--so in the case of the production site, this flag is set to false.

In a subdirectory of the production site, I have a folder containing a testing version of the site. This has its own Application.cfc with debugMode set to true. Other than this flag and changes that we are testing, it's identical to the production Application.cfc.

There haven't been any problems with this UNTIL we added logic for resetting Application.cfc in order to see our changes without waiting for the timeout (which we have set to 30 minutes).

To accomplish this, we added this block to the 'OnRequestStart' function in Application.cfc (it is present on both production and testing versions):

    <cfif StructKeyExists( URL, "reset" )>

        <!--- Reset application and session. --->
        <cfset THIS.OnApplicationStart() />
        <cfset THIS.OnSessionStart() />

    </cfif>

This initially appeared to work fine. If we add '?reset' to the url for any page on the testing version, changes made Application.cfc are reflected immediately, but we quickly discovered a nasty side effect: calling reset on the testing version ALSO changes our production site to use the testing version of Application.cfc, thereby mightily fubaring everything.

Running the '?reset' logic on the production site fixed this problem, but then caused all the testing pages to use the production Application.cfc instead of the testing version. Waiting for the Application.cfcs to time out and refresh automatically made no difference, so now our test environment is messed up.

Any insight into what's going on or what to do would be greatly appreciated as we are fairly stumped. Is this simply a poor architecture? We inherited it and are now quite accustomed to this structure, so so a quick fix would be preferred, but I'm open to suggestions.

Thanks.

+6  A: 

The issue is most likely that the two application.cfc files specify the same application name.

So, they are, in essence, the same application.

So, whether you trigger the refresh from the "Test" site or the "Live" site, its resetting the same application, then re-instantiating the variables from whatever version you issued the reset from.

You need to set the application name for the "Test" application to something different then the live application.

For Test:

<!--- For the "Test" Application --->
<cfset this.name = "TESTApplication">

For Live:

<!--- For the "Live" Application --->
<cfset this.name = "Application">
Edward M Smith
Thanks much. This did the trick.
Dane