creating application scope variables prior to the environment settings are run

57 views
Skip to first unread message

thoen

unread,
Dec 9, 2009, 5:58:47 PM12/9/09
to ColdFusion on Wheels
I am trying to use an application scope variable in my config/
[environment]/settings.cfm file. But it appears this is run prior to
the onapplicationstart code, where I am setting the application
variable.

Do you have a suggestion on where I might put a statement setting the
application variable so that it could be run prior to the code in the
settings file?

Best,
Tom

Indy Nagpal

unread,
Dec 9, 2009, 6:40:36 PM12/9/09
to cfwh...@googlegroups.com
On 1.0 you have a file config/app.cfm that would seem to be the logical place for it.


--

You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.



thoen

unread,
Dec 9, 2009, 10:29:43 PM12/9/09
to ColdFusion on Wheels
Do you know when app.cfm is loaded? I stuck my application variable
assignment in there and it still didn't work. I ended up putting the
assignment in the base settings file, which appears to be called
before the environment settings file, an perhaps makes sense for what
I am using this application variable for anyway.

Thanks for your help.

Tom

raulriera

unread,
Dec 9, 2009, 10:33:17 PM12/9/09
to ColdFusion on Wheels
in app.cfm you will refer to the application scope as "this" I believe
right? (haven't used it yet) or maybe you want to place it on your /
events folder

Dominik

unread,
Dec 10, 2009, 2:09:28 AM12/10/09
to ColdFusion on Wheels
Hi Tom,

personally im "on wheels" for just a couple of days now, so i give no
guarantees ;) but afaik:

the /config/app.cfm is the very first "custom/user-mode" (so outside
the /wheels folder) configuration that gets included.
by taking a quick look, the program-flow should be something like
this:

on every request where railo/cf gets involved (for example index.cfm
or rewrite.cfm if url rewriting is on):

/Application.cfc ("this" points now to the Application component, NOT
the scope!)
(includes:)
- /wheels/functions.cfm (sets rootDir, name and sessionManagement)
- (includes:)
- /config/app.cfm
- /wheels/global/appfunctions.cfm
- (includes:)
- /wheels/global/internal.cfm
- /wheels/global/public.cfm
- /wheels/global/cfml.cfm
- /events/functions.cfm
- /wheels/controller/appfunctions.cfm
- (includes: /wheels/controller/*)
- /wheels/events/on*.cfm

i think thats it. the rest gets included/executed via the on*-Events
in /wheels/events/.
onApplicationStart for example loads the /config/environment.cfm (or
from url.reload if defined) and includes the specific /config/
[environmentname]/settings.cfm for environment-specific settings.
also, all wheels-events (in /wheels/events/on*.cfm) do some wheels-
magic and include the appropriate user-events (in /events/on*.cfm)
upon completion.

@"raulriera": like i mentioned above, "this" points to the
Application.cfc NOT the application scope in app.cfm and all
other .cfm files which are included underneath Application.cfc (like
in the tree above) ;)

hope this helps,
dominik

Per Djurner

unread,
Dec 10, 2009, 12:16:50 PM12/10/09
to cfwh...@googlegroups.com
Sorry, I don't really have a good suggestion for you.
Maybe you can set the application variables right in settings.cfm
though (or include another file that does it)?

Anyway, I think what we should have in the future is
"beforeapplicationstart.cfm" and "afterapplicationstart.cfm" instead
of "onapplicationstart.cfm".
Same goes for all CF events actually (onrequeststart, onsessionstart etc).
This way a developer can always wrap code around the framework
specific code that runs on the events.

Thoughts on that?

Dominik

unread,
Dec 11, 2009, 4:48:18 AM12/11/09
to ColdFusion on Wheels
dont get me wrong, i really like the idea because flexibility is
always a good thing, but i cant really think of any intended use for
that right now,
perhaps because im very new to wheels and cf frameworks at all?!

do you have any example what this could be good for? any "real world"
application?
i would really like to know.

thanks,
dominik

Per Djurner

unread,
Dec 11, 2009, 4:52:21 AM12/11/09
to cfwh...@googlegroups.com
One reason could be performance.
Let's say you want to block bots from hitting your site for example.
Ideally this should be done on the onRequestStart event but before the
framework gets involved with the request (too avoid unnecessary
processing).
Reply all
Reply to author
Forward
0 new messages