On Mon, Jun 22, 2009 at 2:15 PM,
the_one_true_dave_anderson<dave@...> wrote:
> I have a FB5.5 app (with an xml-less config), and there's a function in my
> App.cfc called isProduction() that returns a boolean value. I had been
> setting an application.mode variable (to 'prod' or 'dev') based on the value
> returned by this function, but recently discovered (!) that I could call
> isProduction() from pretty much anywhere. However, after recently deploying
> updates to a testing environment, I found that the function would not
> execute in one of my Model cfc's -- though worked fine in display templates.
> I did/do not have this problem on my local dev environment.
I'm surprised you can call Application.isProduction() from a model CFC
in your local dev environment.
Yes, the variables scope of Application.cfc is available in your
views. It's also available as myFusebox.variables() which you could
use in the controllers (or model circuit if you're using a Fusebox
circuit for the model rather than standalone CFCs).
That said, I really wouldn't recommend this sort of thing. Relying on
Application.cfc methods being available "everywhere" is not very well
structured, to say the least. Application.cfc is meant to handle the
lifecycle of the application: startup/shutdown for application /
session / request. It's not meant to be a 'kitchen sink' for utility
methods.
What I typically do is have some sort of configuration CFC that
encapsulates all the differences between dev / qa / prod / etc as much
as possible and then make that available to other components as needed
(storing it in myFusebox.getApplicationData() for use in views and
controllers and then initializing the model with a reference to that
config CFC as appropriate).
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood