Well you can store it in any persistent scope that will be available
on each page. Request is reasonable enough for a single function,
although if you really wanted to have it cached, you could just as
well store it in application or even server scope. The syntax for
getting it into the request scope is easy enough:
<cffunction name="include" ...>
...
</cffunction>
<cfset request.include = include>
Pretty simple. Note that when you include the file within it, the
include will be relative to the template containing the function. I'm
guessing you already know this, but figured I'd mention it just in
case.
I suspect you'll get different answers about it being good practice. I
know Simon will tell you that way paves the road to insanity, and Ray
will tell you it's the dark side of the force. :) I don't personally
have any objection to it, although I place my non-cfc functions (for
ubiquitous functionality) in libraries which are stored in the request
scope. So in my case, the code contains things like:
request.tapi.getPath(), request.tapi.getURL() and then there are
sub-libraries like request.tapi.html and request.tapi.sql which
contain other functions like request.tapi.sql.update(). Having these
in the request scope does for me probably what having your
request.core cfc does for you -- it makes all these functions easily
accessible to any other CFC or template in the application.
> The code I am working has survived several generations of
> developers and
> is a convoluted mess. I would love nothing more than to
> be able to
> properly scope the variables being used throughout the
> rest of the
> application. The original application developers (if you
> want to call
> them that) did not scope any variables and left that
> entirely to Cold
> Fusion to figure out. The volumes of bad code are
> staggering ...
> changing one item can cause a cascading series of errors.
> I do not have the option of properly scoping their
> variables. But at
> the same time, I would like to be able to call cf tag
> based functions in
> cfscript without scoping issues ... or at least have
> enough knowledge to
> overcome them (facilitates the rewrite we will be doing).
> Is it a good practice to place methods in the request
> scope? My CF has
> become a bit rusty ... how would I do that? Is there a
> more appropriate
> location to store these types of functions?
> Thanks
> Kevin Bridges
> S. Isaac Dealey wrote:
s. isaac dealey 954.522.6080
new epoch : isn't it time for a change?
add features without fixtures with
the onTap open source framework
http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:207174
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54