[ic] Question about Autoload

Mike Heins interchange-users@interchange.redhat.com
Wed Sep 5 13:25:01 2001


Quoting Doug Alcorn (lathi@seapine.com):
> 
> What's defined when the Autoload stuff is done?  I want to do some
> Autoloading on the userdb.  Has the record been read in from the
> database when the autoload is executed?  How can I easily access the
> various fields?  Do I have to use the [data userdb ...] tag?  Wouldn't
> that cause some sort of recursion?  I want to do something like this.

No, you don't want to use the [data ...] tag unless you think you
have done something to $Values. The session is already retrieved
at Autoload time.

> 
> Userdb ....
> 
> Autload <<EOR
> [if data userdb pricefield]
>   [perl] $Config->{PriceField} = $Values->{pricefield} [/perl]
> [/if]
> EOR

This won't be good code, as you will find out. Better would
be:

Autoload <<EOR
[perl]
	return unless $Values->{pricefield};
	$Config->{PriceField} = $Values->{pricefield};
	return;
[/perl]
EOR

> 
> I got the perl snippet from
> http://lists.akopia.com/pipermail/interchange-users/2001-February/004944.html.
> But what I don't know is how the $Values reference gets updated?  Does
> it hold the values of the currently read-in record with keys to all
> the fields?

It holds whatever it held from the last page. When a user logs in,
the database is read and $Values and $Scratch are updated. This is persistent.
By the way, if you think people might fiddle with the pricefield value
(remember, a user can set a $Values simply by accessing a URL) then
it would be good to define pricefield as a Scratch setting and
not for Values.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Experience is what allows you to recognize a mistake the second
time you make it. -- unknown