If I understand the question, you're asking why use request.xxx when xxx does just as 
well?

I think the argument here is that it's supposed to be good programming style to 
separate variables into different scopes, thus preventing you accidentally addressing 
the wrong scope.  The 'rule' I think is that all the variables you use should be in a 
meaningful scope (in CF's case a structure).

The best example I can think of is a web form that edits, say, a user record in the 
database.  Following submission of the form, you might have a number of distinct 
collections of data associated with the user 
  - the original unchanged values
  - the values that include unvalidated changes from the form
  - the validated set of data (that would have 10000 instead of 10,000 and so on).  
The easiest way to juggle these 3 sets of data is via different scopes.  So the 
example here would have user.blah, form.blah and formValidated.blah - 3 different 
values for the same piece of data, but much easier to follow than giving them the same 
name in a different scope.
  ----- Original Message ----- 
  From: Matt Horn 
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, November 05, 2003 9:45 AM
  Subject: Re: [ cf-dev ] Request scope


  My question is this

   why do you NEED or WANT to copy from session to Request when
   <cflock scope="session" timeout="10">
        <cfset userId= session.userId>
        <cfset productionhouseId = session.productionhouseId>
  </cflock>
  works as well

  ----- Original Message ----- 
  From: "Robertson-Ravo, Neil (RX)" <[EMAIL PROTECTED]>
  To: <[EMAIL PROTECTED]>
  Sent: Wednesday, November 05, 2003 11:35 AM
  Subject: RE: [ cf-dev ] Request scope


  > Not sure what your question is..but then again I have had hardly any sleep
  > ;-)  but if it's a way of copying back and forth between the request and
  > session scope..this should work (and there are even easier ways!)
  >
  > <cfparam name="attributes.action" default="session2request"><!--- required
  > --->
  >
  > <cfswitch expression="#attributes.action#">
  > <!--- add session variables to the request scope --->
  > <cfcase value="session2request">
  > <cflock scope="SESSION" type="READONLY" timeout="15">
  >   <cfloop collection="#session#" item="key">
  > <cfset request[key] = session[key]>
  >   </cfloop>
  >   </cflock></cfcase>
  >
  > <!--- add request variables to the session scope --->
  > <cfcase value="request2session">
  > <!--- remove request variables that should not be added to
  > the Session scope --->
  > <cfset excludeList = "hideScript,hideTimeScript">
  > <cfloop list="#excludeList#" index="i">
  > <cfset StructDelete(request, i)>
  > </cfloop>
  >
  > <cfloop collection="#request#" item="key">
  > <cflock scope="SESSION" type="EXCLUSIVE"
  > timeout="15">
  > <cfset session[key] = request[key]>
  > </cflock>
  > </cfloop></cfcase>
  >
  > <cfdefaultcase>
  > The "action" ATTRIBUTE you have passed in is invalid.
  > <cfabort></cfdefaultcase>
  > </cfswitch>
  >
  >
  >
  >
  >
  >
  > -----Original Message-----
  > From: Matt Horn [mailto:[EMAIL PROTECTED]
  > Sent: 05 November 2003 09:35
  > To: [EMAIL PROTECTED]
  > Subject: [ cf-dev ] Request scope
  >
  > Hi
  >
  >  for as long as I have been writing Cold fusion code I have done this:
  > <cflock scope="session" timeout="10">
  >      <cfset request.userId= session.userId>
  >      <cfset request.productionhouseId = session.productionhouseId>
  </cflock>
  > but everything works fine without the request scope
  >
  > <cflock scope="session" timeout="10">
  >      <cfset userId= session.userId>
  >      <cfset productionhouseId = session.productionhouseId> </cflock>
  >
  >
  > so my question is this
  >
  >  Am I correct in setting session variables down to Request scope
  >
  > or will the other way work just as well?
  > and if so .. why even have a request scope?
  >
  > Matt *Newbie
  >
  >
  >
  > |\--------------------/|
  > Matt Horn
  > Web Applications Developer
  > Ph:+2782 424 3751
  > W: http://www.matt-horn.org
  > E:[EMAIL PROTECTED]
  > |\--------------------/|
  >
  > -- 
  > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
  >
  > To unsubscribe, e-mail: [EMAIL PROTECTED]
  > For additional commands, e-mail: [EMAIL PROTECTED]
  > For human help, e-mail: [EMAIL PROTECTED]
  >


  -- 
  ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  For human help, e-mail: [EMAIL PROTECTED]

Reply via email to