On 9/14/05 11:50 PM, "Ski Kacoroski" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am creating a password changing page and I have to use expect to
> access Mac OSX open directory where the passwords reside. Is there a
> nice way where I could make the connection in the cgiapp_init script and
> then have it available for the entire app (kind of like the dbh plugin).
> Right now I create and break the connection each time I need it in the
> application.
>
> Thanks in advance.
Could you do something like this in your app (or in your cgiapp subclass if
you want it to be reused):
sub od_connection {
my $self = shift;
#connection already exists from before....
return ($self->{_od_connection}) if (exists($self->{_od_connection}));
#need to make connection, because it
#doesn't already exist
my $connection = ......
$self->{_od_connection} = $connection;
return $connection;
}
I haven't tested this and I don't know how you are making your connection to
the Open Directory server (fill in the '....' above), but I hope you get the
idea. The first time this is called, either in cgiapp_init or, better, only
when needed (for some requests, you won't need the connection, so why make
it at all for those requests), the connection is made and stored. The
second and all subsequent times, you get the same connection object. Don't
forget to do error checking when making the connection.
HTH,
Sean
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]