Hi Jason.

One more question.  I've been testing request variables and structures - and
I've just started, so if anything doesn't sound absolutely correct, forgive me.

When I tried to set a duplicate function,  request.ses = duplicate(session);  CF
choked on "duplicate" function.

Is the duplicate function available in 4.01 or did it come into being in
4.5n...?

Carol


Carol L. Bluestein
Senior Programmer
NYS Office of Real Property
518-486-6335
[EMAIL PROTECTED]


____________________Reply Separator____________________
Subject:    RE: RE: RE: Request Scope
Author: [EMAIL PROTECTED]
Date:       2/2/01 1:35 PM

Carol,

Your first example is correct. With CF 4.0 and up, the application and
session scopes are ColdFusion structures (as are most other scopes).
Structures organize data in a sort of hierarchy using name-value pairs.
Structures can contain any other variable type, including other structures.
The duplicate() function takes any variable and makes a copy of it into
another variable name. This is why you can duplicate() the entire session
scope. It will take the session scope (a structure) and copy all variables
under it. It will dig down and get any nested structures, arrays, and
queries as well.

CAUTION: When using the duplicate() function on large queries, CF server may
crash. It can cause very low-level errors (C code errors). Sometimes the
only way to get CF working again is to do a complete reboot of the machine.
This is not a problem when working with small queries.

Complex data types can be tough to grasp at first. You can get a visual
representation of them using a custom tag that outputs a representation of
the data. It's available on the Developer Exchange by searching for "dump".
It's the cf_dump tag. I've never used this version of it, but Spectra has a
tag that does the same thing (the DevEx version is probably copied from
Spectra, but I'm not sure), and it's a very useful utility. You can input
any variable name and it will show you what's contained in it. In Spectra
the variable types are color-coded: blue/purple = structure, red = query,
green = array, black border = WDDX string. Hopefully this DevEx tag will use
a similar color-coding scheme.

Oh, and to answer the question about referring to request variables,
something like this would work:

<cfset request.ses = duplicate(session)>
<cfset request.app = duplicate(application)>

<cfoutput>
        <!--- Refer to a session variable --->
        #request.ses.sessionTimeout#

        <!--- Refer to an application variable --->
        #request.app.applicationName#

        <!--- Refer to a nested structure in the session scope --->
        #request.ses.userProfile.username#

        <!--- Refer to an array in the application scope --->
        #request.app.aApplicationIDs[2]#
</cfoutput>

OR:

<!--- Set session and application variables into local scope --->
<cfset currApp = request.app.aApplicationIDs[2]>
<cfset timeout = request.ses.sessionTimeout>

etc.

HTH,

Jason

----
Jason Aden
Allaire Certified Developer
[EMAIL PROTECTED]
www.wwstudios.com

> -----Original Message-----
> From: Carol Bluestein [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 02, 2001 12:20 PM
> To: CF-Talk
> Subject: Re:RE: RE: Request Scope
>
>
> Jason,
> Thank you. Thank you. Thank you.
> That makes so much more sense.
>
> May I trouble you one more time for the code, and I'm sure this
> is showing some
> kind of difficulty on my part understanding complex structures:
>
> Do I set this code for EACH session and application variable or
> does the code
> cover all session/application variables ?
> <cfset request.ses = duplicate(session)>
> <cfset request.app = duplicate(application)>
> OR
> <cfset request.ses.id = duplicate(session.id)>
> <cfset request.ses.code1 = duplicate(session.code1)>
> <cfset request.ses.code2 = duplicate(session.code2)>
> <cfset request.app.dsn = duplicate(application.dsn)>
>
> Depending on the above, how do I reference the request variable in a code?
>
> Thanks again,
> Carol
>
>
> This will make like sooooo much easier.
>
>
>
>
>
> Carol L. Bluestein
> Senior Programmer
> NYS Office of Real Property
> 518-486-6335
> [EMAIL PROTECTED]
>
>
> ____________________Reply Separator____________________
> Subject:    RE: RE: Request Scope
> Author: [EMAIL PROTECTED]
> Date:       2/2/01 11:30 AM
>
> Spectra uses the request scope extensively. It's a good place to put
> thread-safe global variables. What you've heard about eliminating the need
> for session, and application locks is true. You can copy all your session
> and application variables to the request scope and not need to use CFLOCK
> around each call to these variables.
>
> You would do something like this:
>
> <cfset request.ses = duplicate(session)>
> <cfset request.app = duplicate(application)>
>
> This code would go in your application.cfm file so those variables get
> copied every time someone requests a page.
>
> You CANNOT use:
>
> <cfset request.ses = session>
> <cfset request.app = application>
>
> In most languages, including ColdFusion, when you set a variable
> equal to a
> complex data set (like a structure, query, array, etc.), it will create a
> reference back to the complex data set. In other words, it's just
> creating a
> pointer to the original data in the session or application scope,
> so you're
> still not thread safe.
>
> Using the duplicate() function will make a complete copy of those
> structures
> (the session and application scopes are ColdFusion structures) into the
> request scope and you will be accessing the copied data, not the original
> data in in the shared scope.
>
> HTH,
>
> Jason
>
> ----
> Jason Aden
> Allaire Certified Developer
> [EMAIL PROTECTED]
> www.wwstudios.com
>
> > -----Original Message-----
> > From: Carol Bluestein [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 02, 2001 10:25 AM
> > To: CF-Talk
> > Subject: Re:RE: Request Scope
> >
> >
> > Is any one out there using the request variables extensively?
> >
> > I'd like to know more about the request scope and how to use it.
> > I've found
> > very little in my documentation (4.0.1) and have searched the
> > allaire knowledge
> > base with no obvious results (a lot comes up but the titles lead
> > me to believe
> > they were not pertinent).  I've heard that using request scope
> > variables can
> > help limit the "need" for session and/or application variables
> so that the
> > necessity of locking is minimized and in some cases eliminated.
> > I also admit
> > that I could have heard this out of context.
> >
> > Any clarification and information would be appreciated.
> >
> > Thanks, in advance,
> > Carol
> >
> >
> > Carol L. Bluestein
> > Senior Programmer
> > NYS Office of Real Property
> > 518-486-6335
> > [EMAIL PROTECTED]
> >
> >
> > ____________________Reply Separator____________________
> > Subject:    RE: Request Scope
> > Author: [EMAIL PROTECTED]
> > Date:       2/1/01 8:06 PM
> >
> > > The "Request" scope was available in CF 4.0 wasn't it?
> >
> > Yup, just tested on our 4.0.1 server and it worked perfectly
> >
> > Philip Arnold
> > Director
> > Certified ColdFusion Developer
> > ASP Multimedia Limited
> > T: +44 (0)20 8680 1133
> >
> > "Websites for the real world"
> >
> > **********************************************************************
> > This email and any files transmitted with it are confidential and
> > intended solely for the use of the individual or entity to whom they
> > are addressed. If you have received this email in error please notify
> > the system manager.
> > **********************************************************************
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to