Changeset 282

Show
Ignore:
Timestamp:
12/21/06 12:20:33 (2 years ago)
Author:
scorfield
Message:

Addresses #95 by allowing fusebox.xml parameter overrides for lexiconPath and errortemplatesPath
and both of those can be relative (to the application root) or absolute / mapped. In addition
lexicons can now be relative (to the lexicon path) or absolute / mapped.

Location:
framework/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • framework/trunk/.settings/org.eclipse.core.resources.prefs

    r280 r282  
    1 #Wed Dec 20 12:07:13 PST 2006 
     1#Thu Dec 21 11:09:00 PST 2006 
    22eclipse.preferences.version=1 
     3encoding//skeleton/controller/circuit.xml.cfm=UTF-8 
    34encoding//skeleton/fusebox.xml.cfm=UTF-8 
    45encoding//skeleton/model/circuit.xml.cfm=UTF-8 
  • framework/trunk/fuseboxApplication.cfc

    r281 r282  
    9393                                        hint="I am the myFusebox data structure." /> 
    9494                 
    95                 <!--- updated fix for ticket 135 ---> 
     95                <!--- fixes ticket 95 for errortemplates and lexicons ---> 
    9696                <cfset var myVersion = "5.0.1.#REReplace('$LastChangedRevision$','[^0-9]','','all')#" /> 
    9797 
     
    108108                <cfset variables.coreRoot = replace(getDirectoryFromPath(getCurrentTemplatePath()),"\","/","all") /> 
    109109 
    110                 <cfset this.approotdirectory = this.webrootdirectory & replace(arguments.appPath,"\","/","all") /> 
    111                 <cfif right(this.approotdirectory,1) is not "/"> 
    112                         <cfset this.approotdirectory = this.approotdirectory & "/" /> 
    113                 </cfif> 
     110                <cfset this.approotdirectory = normalizePartialPath(this.webrootdirectory & arguments.appPath) /> 
    114111                <!--- remove pairs of directory/../ to form canonical path: ---> 
    115112                <cfloop condition="find('/../',this.approotdirectory) gt 0"> 
     
    302299        </cffunction> 
    303300         
     301        <cffunction name="expandFuseboxPath" returntype="any" access="public" output="false"  
     302                                hint="I expand a path in the context of a Fusebox application."> 
     303                <cfargument name="partialPath" type="any" required="true"  
     304                                        hint="I am the partial path to expand. If I do not begin with a /, prepend the Fusebox application root." /> 
     305 
     306                <cfif left(arguments.partialPath,1) is "/"> 
     307                        <!--- absolute path, i.e., root-relative or mapped ---> 
     308                        <cfreturn replace(expandPath(arguments.partialPath),"\","/","all") /> 
     309                <cfelse> 
     310                        <!--- relative, i.e., relative to the Fusebox application root ---> 
     311                        <cfreturn getApplicationRoot() & arguments.partialPath /> 
     312                </cfif> 
     313                 
     314        </cffunction> 
     315         
    304316        <cffunction name="getFuseboxXMLFilename" returntype="string" access="public" output="false"  
    305317                                hint="I return the actual name of the fusebox.xml(.cfm) file."> 
     
    538550                <cfset var __ext = "." & this.scriptFileDelimiter /> 
    539551                <cfset var __errorFile = this.errortemplatesPath & __type & __ext /> 
    540                 <cfset var __handlerExists = fileExists(getApplicationRoot() & __errorFile) /> 
     552                <cfset var __handlerExists = fileExists(expandFuseboxPath(__errorFile)) /> 
    541553                <cfset var FUSEBOX_APPLICATION_KEY = arguments.appKey /> 
    542554                 
     
    544556                        <cfset __type = listDeleteAt(__type,listLen(__type,"."),".") /> 
    545557                        <cfset __errorFile = this.errortemplatesPath & __type & __ext /> 
    546                         <cfset __handlerExists = fileExists(getApplicationRoot() & __errorFile) /> 
     558                        <cfset __handlerExists = fileExists(expandFuseboxPath(__errorFile)) /> 
    547559                </cfloop> 
    548560                <cfif __handlerExists> 
    549                         <cfinclude template="#getCoreToAppRootPath()##__errorFile#" /> 
     561                        <cfif left(__errorFile,1) is "/"> 
     562                                <cfinclude template="#__errorFile#" /> 
     563                        <cfelse> 
     564                                <cfinclude template="#getCoreToAppRootPath()##__errorFile#" /> 
     565                        </cfif> 
    550566                        <cfset __handled = true /> 
    551567                </cfif> 
     
    746762                        <cfset aLex = structNew() /> 
    747763                        <cfset aLex.namespace = children[i].xmlAttributes.namespace /> 
    748                         <cfset aLex.path = replace(children[i].xmlAttributes.path,"\","/","all") /> 
    749                         <cfif right(aLex.path,1) is not "/"> 
    750                                 <cfset aLex.path = aLex.path & "/" /> 
    751                         </cfif> 
    752                         <cfset aLex.path = getCoreToAppRootPath() & "lexicon/" & aLex.path /> 
     764                        <cfset aLex.path = normalizePartialPath(children[i].xmlAttributes.path) /> 
     765                        <!--- FB41 lexicons are deprecated so we don't support absolute / mapped paths: ---> 
     766                        <cfset aLex.path = getCoreToAppRootPath() & this.lexiconPath & aLex.path /> 
    753767                        <cfset variables.fb41Lexicons[children[i].xmlAttributes.namespace] = aLex /> 
    754768                </cfloop> 
     
    767781                                                        detail="You have attempted to declare a namespace '#aLex.namespace#' (in fusebox.xml) which is reserved by the Fusebox framework." /> 
    768782                                </cfif> 
    769                                 <cfset attributes[attr] = replace(attributes[attr],"\","/","all") /> 
     783                                <cfset attributes[attr] = normalizePartialPath(attributes[attr]) /> 
    770784                                <cfif left(attributes[attr],1) is "/"> 
    771785                                        <!--- assume mapped / root-relative path ---> 
    772786                                        <cfset aLex.path = attributes[attr] /> 
     787                                <cfelseif left(this.lexiconPath,1) is "/"> 
     788                                        <!--- assume mapped / root-relative path ---> 
     789                                        <cfset aLex.path = this.lexiconPath & attributes[attr] /> 
    773790                                <cfelse> 
    774                                         <cfset aLex.path = getApplication().getCoreToAppRootPath() & getApplication().lexiconPath & attributes[attr] /> 
    775                                 </cfif> 
    776                                 <cfif right(aLex.path,1) is not "/"> 
    777                                         <cfset aLex.path = aLex.path & "/" /> 
     791                                        <!--- relative paths ---> 
     792                                        <cfset aLex.path = getCoreToAppRootPath() &  
     793                                                        this.lexiconPath & attributes[attr] /> 
    778794                                </cfif> 
    779795                                <cfset variables.lexicons[aLex.namespace] = aLex /> 
     
    959975                </cfloop> 
    960976                 
     977                <!--- 
     978                        if the user overrides certain path variables, we need to normalize them: 
     979                        - this.parsePath (reset parseRootPath) 
     980                        - this.pluginsPath 
     981                        - this.lexiconPath 
     982                        - this.errortemplatesPath 
     983                        normalizing means changing all \ to / and appending / if not present 
     984                ---> 
     985                <cfset this.parsePath = normalizePartialPath(this.parsePath) /> 
     986                <cfset this.parseRootPath = relativePath(expandFuseboxPath(this.parsePath),getApplicationRoot()) /> 
     987                <cfset this.pluginsPath = normalizePartialPath(this.pluginsPath) /> 
     988                <cfset this.lexiconPath = normalizePartialPath(this.lexiconPath) /> 
     989                <cfset this.errortemplatesPath = normalizePartialPath(this.errortemplatesPath) /> 
     990                 
    961991        </cffunction> 
    962992         
     
    10591089        </cffunction> 
    10601090         
     1091        <cffunction name="normalizePartialPath" returntype="string" access="public" output="false"  
     1092                                hint=""> 
     1093                <cfargument name="partialPath" type="string" required="true"  
     1094                                        hint="" /> 
     1095                 
     1096                <cfset var unixPath = replace(arguments.partialPath,"\","/","all") /> 
     1097                 
     1098                <cfif right(unixPath,1) is not "/"> 
     1099                        <cfset unixPath = unixPath & "/" /> 
     1100                </cfif> 
     1101                 
     1102                <cfreturn unixPath /> 
     1103                 
     1104        </cffunction> 
     1105         
    10611106</cfcomponent> 
  • framework/trunk/fuseboxCircuit.cfc

    r281 r282  
    189189                                 
    190190                        </cftry> 
     191<!---            
     192                        this was initially implemented as part of ticket 135 but feedback on 
     193                        the mailing list seems to indicate people think it is too draconian 
     194                        a restriction, even in strict mode - and I agree! -- Sean Corfield 
    191195                         
    192196                        <cfif variables.fuseboxApplication.strictMode and not circuitImplicit and 
     
    196200                                                detail="The circuit xml file, #circuitFile#, in #variables.fullPath#, uses a different file extension to the application's fusebox xml file. Strict requires consistency." /> 
    197201                        </cfif> 
    198                          
     202 --->                    
    199203                        <cftry> 
    200204                                 
     
    466470                                                        detail="You have attempted to declare a namespace '#aLex.namespace#' (in Circuit #getAlias()#) which is reserved by the Fusebox framework." /> 
    467471                                </cfif> 
    468                                 <cfset attributes[attr] = replace(attributes[attr],"\","/","all") /> 
     472                                <cfset attributes[attr] = variables.fuseboxApplication.normalizePartialPath(attributes[attr]) /> 
    469473                                <cfif left(attributes[attr],1) is "/"> 
    470474                                        <!--- assume mapped / root-relative path ---> 
    471475                                        <cfset aLex.path = attributes[attr] /> 
     476                                <cfelseif left(variables.fuseboxApplication.lexiconPath,1) is "/"> 
     477                                        <!--- assume mapped / root-relative path ---> 
     478                                        <cfset aLex.path = variables.fuseboxApplication.lexiconPath & attributes[attr] /> 
    472479                                <cfelse> 
    473                                         <cfset aLex.path = variables.fuseboxApplication.getCoreToAppRootPath() & variables.fuseboxApplication.lexiconPath & attributes[attr] /> 
    474                                 </cfif> 
    475                                 <cfif right(aLex.path,1) is not "/"> 
    476                                         <cfset aLex.path = aLex.path & "/" /> 
     480                                        <!--- relative paths ---> 
     481                                        <cfset aLex.path = variables.fuseboxApplication.getCoreToAppRootPath() &  
     482                                                        variables.fuseboxApplication.lexiconPath & attributes[attr] /> 
    477483                                </cfif> 
    478484                                <cfset variables.lexicons[aLex.namespace] = aLex /> 
  • framework/trunk/myFusebox.cfc

    r281 r282  
    5151<cfcomponent hint="I provide the per-request myFusebox data structure and some convenience methods."> 
    5252        <cfscript> 
    53         // updated fix for ticket 135 
     53        // fixes ticket 95 for errortemplates and lexicons 
    5454        this.version.runtime     = "5.0.1.#REReplace('$LastChangedRevision$','[^0-9]','','all')#"; 
    5555