in reply to $obj-DESTROY isn't called upon
If so then it is quite possible that the script you are running never actually loses the object (eg it is in a global variable), it survives because it is in a persistent processs, and DESTROY is never going to be called.
Try using Apache's register_cleanup function to register a function that does your cleanup. To do that you will need to keep track of the created objects, and then do the save in your cleanup function. I haven't done that myself, but recent versions of CGI.pm first check whether $ENV{GATEWAY_INTERFACE} exists, and if it does then does it match /^CGI-Perl\//. If it does then mod_perl is on, they require Apache, then later on:
The $NPH doesn't concern you. The Apache->request bit does. You might do that by having in your constructor something like this:if ($MOD_PERL && defined Apache->request) { Apache->request->register_cleanup(\&CGI::_reset_globals); undef $NPH; }
and then in saveall save each method in @OBJ_STORE then discard them all. (Check in your DESTROY whether things have been saved.)if ($MOD_PERL && defined Apache::Request) { Apache->request->register_cleanup(\&saveall); push @OBJ_STORE, $self; }
This is untested, but give it a shot and see if it doesn't work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 1: $obj-DESTROY isn't called upon
by Sinister (Friar) on Jan 31, 2002 at 13:32 UTC | |
by tye (Sage) on Jan 31, 2002 at 17:05 UTC | |
by Sinister (Friar) on Jan 31, 2002 at 17:09 UTC | |
by tye (Sage) on Jan 31, 2002 at 17:14 UTC |