[ic] Sessions no longer preserve "sameness" of references

Andrew Shelansky andrew at lunsfordgroup.com
Mon Sep 13 18:51:45 EDT 2004


On Fri, 2004-09-10 at 19:01, Jon Jensen wrote:
> Also, could you explain the context where you're setting the referent and 
> the reference? It's possible that something in the newer Interchange is 
> making a copy of the %$Scratch space and then you're making a reference to 
> the copy.
[snip]

Just realized that you had asked another important question.

I'm not 100% sure I understand what you are asking, so I'll elaborate on
my previous example and hope that it answers your question.

I have an action.  This action creates an object and puts a reference to
it in

$Scratch->{my_object};

Then:

$CGI->{mv_nextpage} = "mypage";
return 1;

The mypage template has a usertag on it called form... it appears thus:
[form name="myform]
...
[/form]

This form tag is replaced by an HTML form that it pulled out of the
database.  This form is "bound" to $Scratch->{my_object} in that the
form will read the control data from $Scratch->{my_object} when it is
displayed.  As part of its work the [form] tag will store one or more
references into $Scratch->{my_object} into its internal data structure,
which it stores in $Session->{currentForm}.

That is,
$Session->{currentForm}{controlCollection}{myControl}{DbBinding} =
\($Scratch->{my_object}{recordCollection}[0]{myField})

or something very like it.

This part works correctly -- any  data in $Scratch->{my_object} appears
in the form controls as expected.

Then the user enters some data and submits the form.  The ACTION of the
form will be another ActionMap.

Among other things, this ActionMap does something like this:

my $controls = $Session->{currentForm}{controlCollection};
foreach (keys %$controls)
{
	$controls{$_}{DbBinding}->setValue($CGI->{$_});
}

It is here that the problem occurs.  $controls{$_}{DbBinding} is no
longer a reference to $Scratch->{my_object}. It is instead a reference
to an object that is exactly the same -- a deep copy.

This is what I'm trying to fix.

Any thoughts would be appreciated.

-- Andrew Shelansky









More information about the interchange-users mailing list