If all users (ie DSN) then Application *or* Server Scope is open and waiting for you (server if the dsn used by multiple apps etc).
Session if individually used of course.
But, now comes the part where if you integrate these variables within a CFMX CFC framework. If these variables are always setup in the view side of things, and you at times swap and change every application (but not in the cfc) then you could annoy yourself further by constantly referring to them individually (ie application.varX in APPA, and session.varX in APPB, both use the one cluster of CFC's).
So i'd and i'm not sure if this is a problem low level, alias the variables as "request" scope. That way its consistent accross every application, while allowing you to swap and change your shared scopes.
eg. inside your global constants construct, you could put:
if NOT StructKeyExists(session,'dsUser') {
Session.dsUser = "monkey"
Session.dsName = "blah"
}
<!--- Alias it now every time this pageContext is called --->
request.dsUser = Session.dsUser
request.dsName = Session.dsNameThen through out your application you always refer to it as request.dsUser or request.dsName.
This will now allow you to simply swap and change your mind at any given point on whether to use Application or Session (even simply use request) scope... Note: if you were to put request.dsUser = "zebra" session.dsUser would return "zebra" aswell.
(we personally do the above, simply due to our apps having the luxury of Server scope but in some cases we have to revert back to Application scope).
Regards Scott Barnes Senior Web Developer Alpha Business Systems [EMAIL PROTECTED]
1/31 Thompson St Bowen Hills QLD 4006 Ph +61 07 3216 0999 http://www.alphabus.com.au
Ryan Sabir wrote:
Hi all,
I'm just having a think about the best way to set global constants for my applications, these are things like datasource names and passwords, upload directories etc... as far as I know there are a few ways to set these up, these being:
* Setting variables in the Application.cfm file e.g. in the Application.cfm file I have a bunch of lines like <CFSET dsName = "mydsn"> <CFSET dsUser = "theuser"> <CFSET dsPass = "thepass">
then throughout my app, I have lines like: <cfquery username="#dsUser#" password="#dsPass#" name="qName" datasource="#dsName#">
* Setting session variables e.g. in the Application.cfm file I have a bunch of lines like <CFLOCK blah> <CFIF not isDefined("session.dsName")> <CFSET session.dsName = "mydsn"> <CFSET session.dsUser = "theuser"> <CFSET session.dsPass = "thepass"> </cfif> <CFSET session_dsName = "mydsn"> <CFSET session_dsUser = "theuser"> <CFSET session_dsPass = "thepass"> </CFLOCK>
then throughout my app, I have lines like: <cfquery username="#session_dsUser#" password="#session_dsPass#" name="qName" datasource="#session_dsName#">
* Setting application variables Same as session variables, but using the application scope with the required locks around it.
Now of all the methods above, which is the most efficient and fastest? The dumbest way looks like the first method where you are setting request scope variables every time any page is called... but the other methods involve overhead with locking variables whenever they are read.
Is there a best practice for this type of this?
bye!
-----------------------
Ryan Sabir
Newgency Pty Ltd
2a Broughton St
Paddington 2021
Sydney, Australia
Ph (02) 9331 2133
Fax (02) 9331 5199
Mobile: 0411 512 454
http://www.newgency.com/index.cfm?referer=rysig
--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
