ColdFusion users have long wanted a way to define settings per application, rather than server-wide, even within a shared instance. ColdFusion 8 introduced the beginnings of per application settings via Application.cfc (which we introduced in CF7).
To set application settings using Application.cfc, variables are set in the THIS scope. THIS.name to set the application name, THIS.sessionManagement to enable session state management, and so on. In CF8, Application.cfc and the THIS scope can be used to define per application settings. For example, THIS.mappings is a structure which can be used to define ColdFusion mappings. To set a mapping you just modify that structure like this:
<cfset THIS.mappings["/MyStuff"]="c:\inetpub\MyStuff">
To set the Custom Tag path you can update THIS.customtagpaths which is a simple ColdFusion list. You can set the path like this:
<cfset THIS.customtagpaths="c:\inetpub\wwwroot\ben\tags">
Or use ListAppend() to add a path, like this:
<cfset THIS.customtagpaths=ListAppend(THIS.customtagpaths, "c:\inetpub\wwwroot\ben\tags")>
It's clean, simple, highly intuitive, and in CF8, limited to just those two settings - mappings and customtagpaths.
In CF9 (aka Centaur) we may have the opportunity to enhance this functionality. And actually, we've already started doing so. For example, at MAX in Europe I mentioned that CF9 allows for THIS.datasource to be defined as a default datasource, eliminating the need to specify the datasource for each and every query. And that's just an example.
There are others I'd like to see, starting with THIS.logdirectory to set a log file location per application. But, rather than my list of settings, I am interested in yours.
Now, this should go without saying, but I'll say it anyway. When discussing a future product there is no firm commitment being made about any features. Stuff can, and usually does, change. But, having said that ...
What are the settings you'd like to see us support per application in CF9? Feel free to list multiple, but be sure to define them in the order of priority.
(Oh, and before the thread goes off on a tangent, yes, I know we need a way to define on-the-fly datasources as you could in CF5. But no, these are not technically application settings, and are out of scope for this thread).
Perhaps a temp folder for application specific results from GetTempDirectory(). I know when operating on a shared host there's no point to using the temp directory.
It would be nice to be able to specify some other default settings for tags.
For example cfmail (server), cfpop, cfftp, those that do make sense.
+ 1 THIS.defaultAttributes
-----------
THIS.timeZone
THIS.enableWhiteSpaceManagement
THIS.debugIPs
I would like to see per application datasources. Not in the way that I can define which datasource my queries use, but in the way that I can specify a driver, host, port, database, username and password and that the datasource is accessible to me without being defined in the CF Administrator. Like we used to be able to do in CF 5 ...
You could write a UDF that runs onApplicationStart and checks for the existence of the per-application datasource definition(s) you want to use (a particularly named structure in the this scope to be used as an argument collection to the Admin API methods), then checks to see if the datasource is already defined on the server (Admin API), then creates it if not (Admin API). You'd just drop the UDF into Application.cfc and your application becomes portable (as long as you have a mechanism in place to feed the administrator credentials into your UDF on each server you plan to deploy on).
The code examples on this page show how to create datasources programmatically with the Datasource.cfc component.
http://livedocs.adobe.com/coldfusion/8/htmldocs/he...
In addition to the default query object result set that <cfquery> currently returns, I'd like to see the option to return an array of value objects. Not just a standard value object, but the ability to pass a value object that gets populated. This can have 2 major advantages. I'll explain.
For example, to enable this, I would specify a recordObject attribute in my <cfquery> tag:
<cfquery name="users" datasource="#request.dsn#" recordObject="myApplication.vo.UserVO">
SELECT firstName, lastName
FROM users
</cfquery>
This would return an array with each index storing a UserVO that represents a single record in the DB.
When I create UserVO.cfc, I would create a setter that represents each column/property from the db table, like setFirstName(), setLastName(), etc. When pass the object to cfquery, these setters would be implicitly invoked based on columns specified in the SQL statement.
So, WHAT ARE THE ADVANTAGES?
1) Flex - I no longer have to loop over a query object to create an array of objects with CF or an array of structures with a __type__ key; what I get back from <cfquery> will be flex ready.
2) Dynamic Properties - In the object that I pass to <cfquery> I can have additional getters that don't pertain to column in the db, but may act upon data that's returned.
For example, my object could have a getter called getFullName that concatenates getFirstName() with getLastName(). I could also have getters that perform date calculations based on data returned from the database. This is just a couple of examples, but I think this could be very valuable. This can be very advantageous to moving logic away from the view and into an object that represents the data.
/m
Then, in onRequestStart you have a check to see if isDefined('url.reset') and cgi.remote_addr is your IP and if so call the reset function.
To cache on production and reinitialize on every request on development, you can then either:
1. Append an or true to your onRequestStart check in the development copy (quick and dirty method: requires remembering to remove it when you move the code to production)
or
2. Use the domain name or other server variables to differentiate which server you're on in the check and only reinitialize on the development server.
I have the same troubles as Ameen except I already tried using the this.customtagpaths. I have the following code set:
this.customtagpaths=ListAppend(this.customtagpaths, "#getDirectoryFromPath(getCurrentTemplatePath())#org\ews\udf") ;
and it returnes the following error:
Element CUSTOMTAGPATHS is undefined in THIS
So why am I getting this error when everyone else seems to be touting this nice feature? Is there maybe a setting on my local dev machine that needs to be edited? I can't find one.
thanks all,
Chris