Rhesa Rozendaal wrote:
Richard Jones wrote:
A circular ref sounds like an interesting possibility though - how would I track something like that down?

Have a look at Devel::Cycle.

Rhesa,

Yes, that's done it - looks like I had at least 2, possibly 3, separate problems. The CAP::ErrorPage & CAP::DebugScreen plugins were interfering with flash message handling somewhere in my request cycle.

But even after removing these 2 plugins I still had problems with login failure (no entry in the sessions table), which only manifested itself after I removed DebugScreen. Thanks to an idea inspired by Bradley C Bailey in a private communication, I inserted a 'Devel::Cycle::find_cycle($self)' in my cgiapp_init, and it identified a problem in Log::Dispatch LOG_DISPATCH_OPTIONS (I think):

Cycle (1):
        $LIMS::Controller::Search::A->{'__CFG'} => \%B
                  $B->{'log_dispatch'} => \%C
          $C->{'LOG_DISPATCH_OPTIONS'} => \%D
                     $D->{'callbacks'} => \&E
                     $E variable $self => \$F
                                   $$F => \%LIMS::Controller::Search::A

Cycle (2):
$LIMS::Controller::Search::A->{'__LOG_CONFIG'} => \%G
          $G->{'LOG_DISPATCH_OPTIONS'} => \%D
                     $D->{'callbacks'} => \&E
                     $E variable $self => \$F
                                   $$F => \%LIMS::Controller::Search::A

I'm not sure how to interpret Devel::Cycle output, but I think the item it's referring to is this:

LOG_DISPATCH_OPTIONS => {
  callbacks => sub {
    my %h = @_; chomp $h{message};
    my $timestamp = strftime "[%d-%b-%Y %H:%M:%S]", localtime;

    return sprintf "%s %s %s [%.4f sec]\n",
      $timestamp,
      uc $self->authen->username,
      $h{message},
      tv_interval $self->param('t0'), [gettimeofday];
}

I'll have to play around with this (can anyone see the problem here?), but I suspect the callbacks sub has something to do with it. I took the general idea from the CAP::LogDispatch pod. Removal of LOG_DISPATCH_OPTIONS makes the Devel::Cycle message go away, flash messages start to work properly using CAP::Flash (at last!!) and my app returns to normal, except for one remaining issue - when I use a $self->redirect call, I get the following error message:

prerun_mode() can only be called within cgiapp_prerun()! Error at /home/raj/perl5/lib/perl5/CGI/Application/Plugin/Redirect.pm line 24

This does not happen if CAP::DebugScreen is loaded. It turned out that a $SIG{__DIE__} error handler I was using in Dispatch was responsible (yet to identify why), but its malign effect was 'masked' if DebugScreen was also loaded, so I wonder whether DebugScreen is in general responsible for suppressing bugs in cgiapp applications, as that's 2 issues in my app that it apparently masked.
--
Richard Jones

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to