Escape Keys - TomdeMan's Blog

The latest release of Coldbox 2.6.0 RC1 is like every other Coldbox release...Filled with goodies.

For now, I am keying in on the Environment Interceptor. It allows you to specify a different set of configuration settings based on the environment your application is running in. You are no longer limited to a single config file and the settings bound to it.

By default, Luis uses URLS specified in the environments.xml and looks for them in the cgi.http_host. While it is effective, I have always liked the flexibility of regular expressions.

I have updated the code to accept a PATTERNS attribute from the config xml file and use the pattern as a regular expression against the cgi.http_host.

It extends the environmentControl interceptor that is distributed with CB, and is completely backward compatible.

Get the CODE - EnvironmentControl.zip

If you want to use the PATTERNS leave the URLS empty.

I thought about using both URLS and PATTERNS together, but with regEx you can pretty much capture any URL.

The environments.xml.cfm would look like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<environmentcontrol>
   <environment name="development" urls="" patterns=".local">
      <Setting name="DebugMode"                  value="true" />
      <Setting name="DebugPassword"               value="" />
      <Setting name="ReinitPassword"               value="" />
      <Setting name="EnableDumpVar"               value="true" />
      <Setting name="HandlersIndexAutoReload"         value="true" />
      <Setting name="ConfigAutoReload"            value="true" />
      <Setting name="HandlerCaching"               value="false" />
      <Setting name="EventCaching"               value="false" />
   </environment>
</environmentcontrol>

The interceptor in the config.xml.cfm would look like:
(only difference here is the class path - no longer points to coldbox.system.interceptors)

<Interceptor class="interceptor.environmentControl">
   <Property name='configFile'>config/environments.xml.cfm</Property>
   <Property name='fireOnInit'>false</Property>
</Interceptor>

For more on the latest release, check out What's New in Coldbox 2.6.0

Comments:

[Add Comment]

Rob Gonda says:

Useful, love it

5/29/08 4:12 PM

[Add Comment]