Changeset 2649

Show
Ignore:
Timestamp:
09/25/09 16:34:51 (4 years ago)
Author:
lmajano
Message:

Ticket #857
fixed issues when loading ses configuration files outside of the root.

Location:
coldbox/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/system/interceptors/SES.cfc

    r2614 r2649  
    2626        <cffunction name="configure" access="public" returntype="void" hint="This is where the ses plugin configures itself." output="false" > 
    2727                <cfscript> 
    28                         var configFilePath = "/"; 
    29                         var controller = getController(); 
    30                         var local = structnew(); 
    31                          
    32                         // If AppMapping is not Blank check 
    33                         if( controller.getSetting('AppMapping') neq "" ){ 
    34                                 configFilePath = configFilePath & controller.getSetting('AppMapping') & "/"; 
    35                         } 
    36                          
    3728                        // Setup the default interceptor properties 
    3829                        setRoutes( ArrayNew(1) ); 
     
    4334                        setAutoReload(false); 
    4435                         
    45                         // Verify the config file, else set it to our convention. 
    46                         if( not propertyExists('configFile') ){ 
    47                                 setProperty('configFile','config/Routes.cfm'); 
    48                         } 
    49                          
    50                         // Setup the config Path 
    51                         configFilePath = configFilePath & reReplace(getProperty('ConfigFile'),"^/",""); 
    52                          
    53                         // We are ready to roll. Import config to setup the routes. 
    54                         try{ 
    55                                 $include(configFilePath); 
    56                         } 
    57                         catch(Any e){ 
    58                                 $throw("Error including config file: #e.message# #e.detail#",e.tagContext.toString(),"SES.executingConfigException"); 
    59                         } 
    60                          
    61                         // Validate the base URL 
    62                         if ( len(getBaseURL()) eq 0 ){ 
    63                                 $throw('The baseURL property has not been defined. Please define it using the setBaseURL() method.','','interceptors.SES.invalidPropertyException'); 
    64                         } 
     36                        //Import Config 
     37                        importConfiguration(); 
    6538                         
    6639                        // Save the base URL in the application settings 
     
    6942                </cfscript> 
    7043        </cffunction> 
     44         
    7145 
    7246<!------------------------------------------- INTERCEPTION POINTS -------------------------------------------> 
     
    784758                </cfscript> 
    785759        </cffunction> 
     760         
     761        <!--- importConfiguration ---> 
     762        <cffunction name="importConfiguration" output="false" access="private" returntype="void" hint="Import the routing configuration file"> 
     763                <cfscript> 
     764                        var appLocPrefix = "/"; 
     765                        var configFilePath = ""; 
     766                        var controller = getController(); 
     767                        var local = structnew(); 
     768                         
     769                        // Verify the config file, else set it to our convention in the config/Routes.cfm 
     770                        if( not propertyExists('configFile') ){ 
     771                                setProperty('configFile','config/Routes.cfm'); 
     772                        }                        
     773                         
     774                        //Check if file exists in our App 
     775                        if( len(getSetting('AppMapping')) ){ 
     776                                appLocPrefix = appLocPrefix & getSetting('AppMapping') & "/"; 
     777                        } 
     778                         
     779                        // Setup the config Path for relative location first. 
     780                        configFilePath = appLocPrefix & reReplace(getProperty('ConfigFile'),"^/",""); 
     781                        if( NOT fileExists(expandPath(configFilePath)) ){ 
     782                                //Check absolute location as not found inside our app 
     783                                configFilePath = getProperty('ConfigFile'); 
     784                                if( NOT fileExists(expandPath(configFilePath)) ){ 
     785                                        $throw(message="Error locating routes file: #configFilePath#",type="SES.ConfigFileNotFound"); 
     786                                }        
     787                        } 
     788                         
     789                        // We are ready to roll. Import config to setup the routes. 
     790                        try{ 
     791                                $include(configFilePath); 
     792                        } 
     793                        catch(Any e){ 
     794                                $throw("Error including config file: #e.message# #e.detail#",e.tagContext.toString(),"SES.executingConfigException"); 
     795                        } 
     796                         
     797                        // Validate the base URL 
     798                        if ( len(getBaseURL()) eq 0 ){ 
     799                                $throw('The baseURL property has not been defined. Please define it using the setBaseURL() method.','','interceptors.SES.invalidPropertyException'); 
     800                        } 
     801                </cfscript> 
     802        </cffunction> 
    786803 
    787804</cfcomponent> 
  • coldbox/trunk/testharness/config/coldbox.xml.cfm

    r2508 r2649  
    162162                </Interceptor> 
    163163                <Interceptor class="coldbox.system.interceptors.SES"> 
    164                         <Property name="configFile">/config/routes.cfm</Property> 
     164                        <Property name="configFile">config/routes.cfm</Property> 
    165165                </Interceptor> 
    166166