I've got the following method in my root CFC:

<cffunction     name="isApplication"
                        hint="Returns true if the application scope has been
instantiated."
                        returntype="boolean"
                        access="public"
                        output="No">

                <!--- Try the app --->
        <cfif IsDefined("Application")>
                <cfreturn true />
        <cfelse>
                <cfreturn false />
        </cfif>

</cffunction>

It seems to work pretty well, but every once in a while I'm getting odd
results. 

I've also tried:

<cffunction     name="isApplication"
                        hint="Returns true if the application scope has been
instantiated."
                        returntype="boolean"
                        access="public"
                        output="No">
                <!--- Set Local Scope --->
        <cfset var local = StructNew() />

        <cftry>
                <cfset
application.SomeReallyLongVariableNameThatWontBeUsedElsewhere = true />
        <cfcatch type="any">
                <cfreturn false />
        </cfcatch>
        </cftry>

</cffunction>

But this has also been a little flakey (and seems like it would have more
overhead for having to generate an error instance).

Basically I'm looking for the fastest, best way to do this.

(My CFCs store metadata about themselves - if they're called in an
application they store it the application scope, if they're called outside
of an application they store it in the server scope.)

Jim Davis





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:199384
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

Reply via email to