Fusebox 不解析 xml 文件
目前,在 application.cfc 中,我扩展了 Fusebox 5.5 框架。 然后在下面的 OnRequestStart 方法中,我根据特定条件设置保险丝盒模式。
问题是,有时,无论我进行什么更改,fusebox xml 文件都不会重新解析。如果我使用 url 变量fusebox.parse=true&fusebox.loadclean=true&fusebox.password=xxx 强制重新解析,则文件会再次解析。
几乎就像 Fusebox 仍处于生产模式一样,即使当我转储 FUSEBOX_PARAMETERS.mode 时它显示“development-full-load”,
这可能是什么原因造成的?在下面的代码中,fusebox 模式的操作方式是否正确,还是应该在其他地方进行这种设置(显然除了fusebox.xml 之外)?
任何帮助都会很棒。 谢谢
<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>
<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>
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>
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅,
FUSEBOX_PARAMETERS
存储在application
范围内,默认情况下它们包含在巨大的容器application.fusebox
中。 Fusebox 设置是在调用super.onApplicationStart()
时填充的,因此在onRequestStart
中修改它们没有意义。我建议将 cfswitch 代码移至定义应用程序设置的组件主体中。
在
onRequestStart
中,您可以强制应用程序重新启动以重新读取设置,可能是这样的:请注意,
fusebox.loadapp
不是内置的 Fusebox 属性,它只能工作对于您的应用程序,为了方便起见,只需像其他应用程序一样添加前缀即可。这样您就可以重新读取应用程序的单调。See,
FUSEBOX_PARAMETERS
are stored inapplication
scope, by default they are included in huge containerapplication.fusebox
. Fusebox settings are populated whensuper.onApplicationStart()
invoked, so modifying them inonRequestStart
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: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.