> <!--- COLDFUSION COMPONENT: hcp.cfc ---> <cfcomponent
> displayname="hcp" extends="main" hint="I contain methods that
> load and access information for the entire hcp.com application.">
>
>
> <!--- METHOD: initializeObject() --->
> <cffunction name="initializeObject" access="public"
> output="no" hint="I prepare content, routines, and objects
> for hcp.com">
>
> <!--- Attempt to run the function code --->
> <cftry>
>
>
> <!--- Obtain the top-level market topics from the database --->
> <cfinvoke
> component="#server.database#"
> method="selectTopics"
> prefixFilter="m1"
> returnvariable="sthcpInfo.aMarkets">
First problem. Your method creates a variable called sthcpInfo.aMarkets. If
this variable is only meant to last for the execution of this method, you
should var scope it. Also, I'd called it bad practice to have cfinvoke
return a variable named x.y. Yes, CF will automatically create a structure
and member for you, but you should really just return the variable as
aMarkets or something else. Assuming you return it as aMarkets, you should
add
<cfset var aMarkets = "">
at the top of your cffunction call. Ditto for any other variable you create,
like current_market. Not var scoping your variables can defintely lead to
issues under load.
> <!--- For each market returned by the database... --->
> <cfloop from="1" to="#ArrayLen(sthcpInfo.aMarkets)#"
> step="1" index="current_market">
> <cflock scope="SERVER" type="EXCLUSIVE" timeout="30">
>
> <!--- Create a new topic object for this market in server
> memory--->
> <cfset
> "server.#sthcpInfo.aMarkets[current_market].topic#" =
> CreateObject("component", "cf_components.topic")>
Why do you do this? You are already storing the CFC itself in server memory
- why not store these values in the CFC itself - in the Variables scope.
Then the values will exist as long as the CFC itself exists.
> <!--- run the initializeObject routine to init this object--->
> <cfset
> Evaluate("server.#sthcpInfo.aMarkets[current_market].topic#.in
> itializeObject(sthcpInfo.aMarkets[current_market].topic)")>
Not that it matters, but you don't need to use evaluate here. I'd change it
to
<cfset
server[sthcpinfo.amarkets[current_market]].topic.initializeObject(....)>
Again though, I'd move this stuff out of the server scope anyway.
Thats all for now - I'd defintely add the var scoping.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

