Dave,
I have just started to use XML for file settings, so take this as a bigger's
stab.
I have about 80 lines in my application.cfc that sets things like file
locations, menus, security context, etc. I am in the process of moving them
into XML files, one for each environment (dev, test, production). I then
just read, <CFFile>, the xml file in the <CFParse> into an XML structure
which I same to Application.defaults.
One of my defaults are Database settings (DSN, ID, Password) which I pass to
each CFC when I initialize it ( testObj(UserKey=session.User.getUser(),
Settings = application.defaults.settings)
In my CFC's, I don't use "this" because that enables direct access to the
variables. I use "instance":
<cfset instance.Settings = arguments.Settings />
<cfset instance.UserKey = arguments.UserKey />
Then when I need to see something in the object, I use a get to receive it:
<cfset seeInfo = testObj.getInfo />
Then in testObj I have
<cffunction name="testObj" ... />
<cfreturn instance.AskedForInfo />
</cfFunction>
If AskedForInfo is a structure, then I always return
duplicate(instance.AskedForInfo) so that the user doesn't have direct access
to the object.
Hope this helps,
Andy
-----Original Message-----
From: dave [mailto:[EMAIL PROTECTED]
Sent: Friday, September 16, 2005 2:27 PM
To: CF-Talk
Subject: using an xml file for cfc settingsray style
this ? is based off of raymond article on using ini or xml files for
settings.
I have 2 sites i am doing that need to share the same data on 2 diff urls,
well some of the data but I am going to use the same db for both of them, so
I figured the xml file is the way to go.
One thing I haven't gotten yet is how to use these settings properly with
cfcs.
On rays article it shows how to make and initialize the xml file but the
part I'm blundering is actually using the settings after that.
SO once you have the settings in variables how do you best invoke the cfc
with them and then use the variables in the cfc.
The only examples I have seen of this is in rays forum app and I dont quite
get it.
The main thing is to get the db un and password in the cfcs without
manually doing each one, I haven't seen anything written on this yet.
as usual, I'm sure I make no sense at all ;)
~Dave the disruptor~
"Some people just don't appreciate how difficult it is to dispense wisdom
and abuse at the same time."
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:218563
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54