root / framework / tags / fusebox5A2 / fusebox5.cfm

Revision 102, 5.6 kB (checked in by scorfield, 3 years ago)

Updated version to 5.0.0.A.2.
Refactored force-load when versions differ code.
This is Alpha 2!

Line 
1<cftry>
2<cfsilent>
3<!---
4Fusebox Software License
5Version 1.0
6
7Copyright (c) 2003, 2004, 2005, 2006 The Fusebox Corporation. All rights reserved.
8
9Redistribution and use in source and binary forms, with or without modification, are permitted
10provided that the following conditions are met:
11
121. Redistributions of source code must retain the above copyright notice, this list of conditions
13   and the following disclaimer.
14
152. Redistributions in binary form or otherwise encrypted form must reproduce the above copyright
16   notice, this list of conditions and the following disclaimer in the documentation and/or other
17   materials provided with the distribution.
18
193. The end-user documentation included with the redistribution, if any, must include the following
20   acknowledgment:
21
22   "This product includes software developed by the Fusebox Corporation (http://www.fusebox.org/)."
23
24   Alternately, this acknowledgment may appear in the software itself, if and wherever such
25   third-party acknowledgments normally appear.
26
274. The names "Fusebox" and "Fusebox Corporation" must not be used to endorse or promote products
28   derived from this software without prior written (non-electronic) permission. For written
29   permission, please contact fusebox@fusebox.org.
30
315. Products derived from this software may not be called "Fusebox", nor may "Fusebox" appear in
32   their name, without prior written (non-electronic) permission of the Fusebox Corporation. For
33   written permission, please contact fusebox@fusebox.org.
34
35If one or more of the above conditions are violated, then this license is immediately revoked and
36can be re-instated only upon prior written authorization of the Fusebox Corporation.
37
38THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40DISCLAIMED. IN NO EVENT SHALL THE FUSEBOX CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY
41DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
47-------------------------------------------------------------------------------
48
49This software consists of voluntary contributions made by many individuals on behalf of the
50Fusebox Corporation. For more information on Fusebox, please see <http://www.fusebox.org/>.
51
52--->
53
54<!--- FB5: allow "" default - FB41 required this variable: --->
55<cfparam name="FUSEBOX_APPLICATION_PATH" type="string" default="" />
56<!--- FB5: application key - FB41 always uses 'fusebox': --->
57<cfparam name="FUSEBOX_APPLICATION_KEY" type="string" default="fusebox" />
58
59<cfparam name="attributes" type="struct" default="#structNew()#" />
60<cfset structAppend(attributes,URL,true) />
61<cfset structAppend(attributes,form,true) />
62
63<!--- FB5: myFusebox is an object but has FB41-compatible public properties --->
64<cfset myFusebox = createObject("component","myFusebox").init(FUSEBOX_APPLICATION_KEY,attributes) />
65<!--- FB5: indicates whether application was started on this request --->
66<cfset myFusebox.applicationStart = false />
67<!---
68        complex condition allows FB5 to drop into a running FB41 site and force re-init because
69        FB41 application.fusebox will not have compileRequest() method - this should make upgrades
70        to FB5 easier!
71--->
72<cfif not structKeyExists(application,FUSEBOX_APPLICATION_KEY) or myFusebox.parameters.load>
73        <cflock name="#application.ApplicationName#_fusebox_#FUSEBOX_APPLICATION_KEY#" type="exclusive" timeout="300">
74                <cfif not structKeyExists(application,FUSEBOX_APPLICATION_KEY) or myFusebox.parameters.load
75                                or not structKeyExists(application[FUSEBOX_APPLICATION_KEY],"compileRequest")
76                                or not isCustomFunction(application[FUSEBOX_APPLICATION_KEY].compileRequest)>
77                        <cfset application[FUSEBOX_APPLICATION_KEY] =
78                                        createObject("component","fuseboxApplication")
79                                                .init(FUSEBOX_APPLICATION_KEY,FUSEBOX_APPLICATION_PATH,myFusebox) />
80                        <cfset _fba = application[FUSEBOX_APPLICATION_KEY] />
81                        <cfif myFusebox.parameters.parseall>
82                                <cfset _fba.compileAll(myFusebox) />
83                        </cfif>
84                        <cfparam name="attributes.#_fba.fuseactionVariable#" default="#_fba.defaultFuseaction#" />
85                        <cfset myFusebox.applicationStart = true />
86                        <!--- force parse after reload for consistency --->
87                        <cfset myFusebox.parameters.parse = true />
88                        <!--- FB5: new appinit include file --->
89                        <cftry>
90                                <cfinclude template="#_fba.getCoreToAppRootPath()#fusebox.appinit.cfm" />
91                        <cfcatch type="missinginclude" />
92                        </cftry>
93                <cfelse>
94                        <cfset _fba = application[FUSEBOX_APPLICATION_KEY] />
95                        <cfparam name="attributes.#_fba.fuseactionVariable#" default="#_fba.defaultFuseaction#" />
96                </cfif>
97        </cflock>
98<cfelse>
99        <cfset _fba = application[FUSEBOX_APPLICATION_KEY] />
100        <cfparam name="attributes.#_fba.fuseactionVariable#" default="#_fba.defaultFuseaction#" />
101</cfif>
102<cftry>
103        <cfinclude template="#_fba.getCoreToAppRootPath()#fusebox.init.cfm" />
104<cfcatch type="missinginclude" />
105</cftry>
106<cfset _parsedFile = _fba.compileRequest(attributes[_fba.fuseactionVariable],myFusebox) />
107</cfsilent><cfprocessingdirective suppresswhitespace="true">
108<cfinclude template="#_parsedFile#" />
109</cfprocessingdirective>
110<cfcatch type="fusebox">
111        <cfif not isDefined("_fba.errortemplatesPath") or not _fba.handleFuseboxException(cfcatch)>
112                <cfrethrow />
113        </cfif>
114</cfcatch>
115</cftry>
Note: See TracBrowser for help on using the browser.