Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-14 Thread Don

Hi guys, just came in this morning. thanks for the responses will try out the 
suggested code and get back to you.

I'm on CF9/Fusebox 5.5 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342189
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-14 Thread Don

Thanks Matt your suggestion worked.


cfset session.myvariable = duplicate(form) /
cflocation url=foo.cfm /


Odd this is the first time I've encountered this specific behaviour in 
Coldfusion. Thanks a byunch was spinning my wheels on this. 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342190
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-14 Thread Matt Quackenbush

Cool beans.  Always glad to help.  Thanks for reporting back.  :-)


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342198
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Dave Watts

 Presumably you are doing something like so...

 cfset session.myvariable = form /
 cflocation url=foo.cfm /

 I have not tested it, but I am guessing that you are loosing the session
 variables because you are creating a _reference_ to the form scope.  When
 you redirect, the form scope is now empty, and therefore, any and all
 references to it will be empty.  To create a session variable that actually
 holds the *value* (rather than the reference), use duplicate().

 cfset session.myvariable = duplicate(form) /
 cflocation url=foo.cfm /

This is not how references work. You can safely create a reference to
the form (which is itself just a reference) and when the form goes out
of scope, the reference you subsequently created will still be
available. There's no need to use Duplicate here, and it's
unnecessarily expensive.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsit

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342173
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Matt Quackenbush

Dave, as you well know I usually agree with you.  However, in this case, I
do not agree with you at all.  Why?  Because you are 100% wrong in your
statement.  What I showed is **exactly** how references work.

1) If you create a _reference_ to something as my code example did...

cfset session.myvariable = form /

2) and then you change the original...

cflocation url=foo.cfm /

3) the reference **will** be updated to match the value to which it is
pointing at.

In ColdFusion, structures are passed _by reference_ rather than _by value_.
The only way to pass a structure in CF by reference is by using
duplicate().  Can it be an expensive operation?  Ayep.  Is it necessary when
you want to pass by value rather than reference?  Ayep.

The 'form' scope, like all others in CF, is a structure.  Therefore the
rules about reference and value apply to it just as though you had created
the structure yourself with structNew().

Test the code I wrote.  You'll see that I am right.

Now then, if you are setting your session values like so...

cfscript
session.myvariable = {};
for ( key IN form )
{
 session.myvariable[key] = form[key];
}
/cfscript

... then you are creating brand new variables that will are _value_ based
rather than simply a reference to the form scope.  If this is what you are
doing, then, of course, changing the form scope (of form-scoped variables)
will have no bearing on the session variables you created.

HTH


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342174
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Matt Quackenbush

On Sun, Feb 13, 2011 at 11:36 AM, Matt Quackenbush wrote:

 The only way to pass a structure in CF by reference is by using
 duplicate().



Oops.  That is suppose to say

The only way to pass a structure in CF by value is by using duplicate().


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342175
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Sean Corfield

On Sun, Feb 13, 2011 at 9:36 AM, Matt Quackenbush quackfu...@gmail.com wrote:
 Dave, as you well know I usually agree with you.  However, in this case, I
 do not agree with you at all.  Why?  Because you are 100% wrong in your
 statement.  What I showed is **exactly** how references work.

Well, yes, your code was about references but unfortunately form scope
is created anew on each request in ACF so whilst

 cfset session.myvariable = form /

leaves session.myvariable pointing at a struct (that was the form
scope on that request), by the time you do this:

 cflocation url=foo.cfm /

The name form is bound to a new struct and the original
session.myvariable is unchanged.

I tried it on Railo and discovered that the form scope is somehow
reused across multiple requests - so on Railo, your logic would be
correct. That's interesting and I'll have to take that up with
engineering to find out why / how it's different.

Which begs the question of the Original Poster: Don / Dan - are you
running on ACF or Railo?
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

If you're not annoying somebody, you're not really alive.
-- Margaret At

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342184
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Sean Corfield

On Sun, Feb 13, 2011 at 7:59 PM, Sean Corfield seancorfi...@gmail.com wrote:
 I tried it on Railo and discovered that the form scope is somehow
 reused across multiple requests - so on Railo, your logic would be
 correct. That's interesting and I'll have to take that up with
 engineering to find out why / how it's different.

Some experimentation yields the answer. In ACF, form is a fairly
regular struct object that is created and populated afresh on each
request with whatever is posted into that request. In Railo, form is a
smart object that behaves like a proxy to the current request's form
data so, whilst the contents of the form scope are populated afresh on
each request, the form scope itself is a proxy to that data rather
than actually containing it.
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342185
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Matt Quackenbush

I have two different CF9 installations that behave the way I described.  It
actually caught me out on a quickie application I did for someone awhile
back, because I did not expect that behavior.  But that's exactly what it
does on two different installations.  shrug


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342186
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-13 Thread Sean Corfield

On Sun, Feb 13, 2011 at 8:58 PM, Matt Quackenbush quackfu...@gmail.com wrote:
 I have two different CF9 installations that behave the way I described.

Odd. I couldn't repro on CF9.0.1 locally. Do you have a small test
case that shows form scope behaving like that for you? I'd love to try
it on my setup. Thanx!
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342187
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Fusebox seemingly clearing contents of session variables on relocation

2011-02-12 Thread Matt Quackenbush

Presumably you are doing something like so...

cfset session.myvariable = form /
cflocation url=foo.cfm /

I have not tested it, but I am guessing that you are loosing the session
variables because you are creating a _reference_ to the form scope.  When
you redirect, the form scope is now empty, and therefore, any and all
references to it will be empty.  To create a session variable that actually
holds the *value* (rather than the reference), use duplicate().

cfset session.myvariable = duplicate(form) /
cflocation url=foo.cfm /

HTH


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342171
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm