CFCs When you must use explicit naming -- Frameworks Potential Gotcha

Since HHWD often uses test databases and testing areas for internal development servers, and online client sandboxes, we set up our application.cfc to refer to many items by reference.

Instead of using datasource='databasefoo'

We will have an application.cfc entry:

<cfset application.dsn = 'databasefoo'>

then in the CFC cfquery use

<cfquery datasource='#application.dsn#'...
since the testing database and sandbox database aren't our production databases, we want to be able to quickly update just the application.cfc and have it point to the correct database without having to do perform a find/replace across our site.

Similarly, We do the similar setups for CFCs. Since the testing server and sandboxes a different directory structure than our production area, we normally use:

and then refer to it in our code as:

This all works great .... EXCEPT when your framework/OO needs and wants an explicit reference. This would be cases where you are establishing a bean or using a returntype:

in DAOs:

<cffunction name="read" output="false" access="public" returntype="datafoo.cfc.data">
You must enter the explicit returntype. Putting the #application.cfc# in the returntype field throws a generic 500 "Server busy or starting" error. Cryptic and not particularly useful in the measure.

The same situation occurs when you declare a bean argument with the cfc as its type:

<cfargument name="bean" required="true" type="datafoo.cfc.data">

You must use the explicit reference here as well.

As you can tell, I just spent a few hours in the school of head-bangers figuring out the issue... after I did a sitewide replacement of all "datafoo.cfc." with "#application.cfc#".

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact HHWD