Kristen Winsor wrote: > My question instead of having to make code changes when copying files from > development to staging to production--is the following piece of code > "safe" to utilize. > > <cfset application.Root = "http://#cgi.server_name#:#cgi.SERVER_PORT#/"> > > <cfif cgi.server_name CONTAINS 'dev'> > <cfset APPLICATION.DSN = "devData"> > <cfset fromEmailName = "DevelopmentSite"> > > <cfelseif right(application.root,3) eq "88/"><!--- staging ---> > <cfset APPLICATION.DSN = "dataStaging"> > <cfset fromEmailName = "StagingSite"> > > <cfelseif right(application.root,3) eq "82/"><!--- this is production ---> > <cfset APPLICATION.DSN = "dataprod"> > <cfset fromEmailName = "Intranet"> > </cfif> >
The problem you have is that your application name, from your cfapplication tag, is the same in all three of the above cases, so you will be overwriting application.dsn. eg. UserA is working on the dev site, so accesses the application.cfm/cfc and sets application.dsn to be devData. UserB is a standard user, they access the site and they set application.dsn to be dataprod. Both of these users are effecting changes to the same variable in the same application space - the same will be happening to application.root as well, so if you get two users accessing the dev and production sites at once, there's no telling what application.dsn could be set to. You have 2 choices. You can either check the port number above the <CFApplication> tag and append something to the application name, say "_dev" for developement, "_stage" for the staged site and "_live" for the production site. This would ensure that each site would be working in its own application space. Or you can change application.dsn to be say request.dsn instead. This way the variable would only be around for one discrete request. It should be noted that you are currently setting application.dsn on every request and rather than just once when the application starts. Hope this helps Stephen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:15:1579 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
