Currently, in the application.cfc, I extend the Fusebox 5.5 Framework. Then in the OnRequestStart method below, I set the fusebox mode depending on a certain condition.
The problem is that sometimes, the fusebox xml files do not reparse no matter what changes I make. If I force a reparse using the url variables fusebox.parse=true&fusebox.loadclean=true&fusebox.password=xxx then the files parse again.
It is almost like Fusebox remains in production mode even though when I dump the FUSEBOX_PARAMETERS.mode it says "development-full-load"
What could be causing this? Is the way that the fusebox mode is being manipulated correct in the code below or should that kind of setting be done somewhere else (besides the fusebox.xml obviously)??
Any help would be great. Thanks
<cffunction name="onRequestStart">
<cfset variables.server_type = "Development" />
<cfswitch expression="#variables.server_type#">
<cfcase value="development">
<cfset FUSEBOX_PARAMETERS.mode = "development-circuit-load" />
<cfset FUSEBOX_PARAMETERS.debug = true />
<cfset request.component_reload = true />
</cfcase&g开发者_StackOverflow中文版t;
<cfdefaultcase>
<cfset FUSEBOX_PARAMETERS.mode = "production" />
<cfset FUSEBOX_PARAMETERS.debug = false />
<cfset request.component_reload = false />
</cfdefaultcase>
</cfswitch>
<cfif (StructKeyExists(attributes, "fusebox.loadapp") AND attributes.fusebox.password EQ application.fusebox.password) OR FUSEBOX_PARAMETERS.mode NEQ application.fusebox.mode>
<cfset this.onApplicationStart() />
</cfif>
<cfset superReturn = super.onRequestStart(arguments.1) />
</cffunction>
See, FUSEBOX_PARAMETERS
are stored in application
scope, by default they are included in huge container application.fusebox
. Fusebox settings are populated when super.onApplicationStart()
invoked, so modifying them in onRequestStart
does not make sense.
I would recommend to move your cfswitch code into the component body where you define application settings.
In onRequestStart
you can force the application restart to reread the settings, possibly something like this:
<cfif StructKeyExists(attributes, "fusebox.loadapp") AND attributes["fusebox.password"] EQ application.fusebox.password>
<cfset this.onApplicationStart() /
</cfif>
Please note that fusebox.loadapp
is not built-in Fusebox attribute, it will work only for your app, simply prefixed like others for convenience. This way you can reread the singletones of your application.
精彩评论