Loading ...
Sorry, an error occurred while loading the content.

a new API proposal for passing $r to CGI.pm/CGI::Cookie

Expand Messages
  • Stas Bekman
    Hi Lincoln, Nick Tonkin is working on the patch to make CGI::Cookie work properly under modperl 2.0 in pre-response handlers, and the issue of providing the
    Message 1 of 40 , Apr 10 8:18 PM
    • 0 Attachment
      Hi Lincoln,

      Nick Tonkin is working on the patch to make CGI::Cookie work properly under
      modperl 2.0 in pre-response handlers, and the issue of providing the API for
      passing $r to CGI.pm and CGI::Cookie has been raised again.

      I'm proposing the following API:

      - CGI.pm:

      CGI->r($r); # for non-OO API

      or

      my $q = CGI->new;
      $q->r($r); # for OO API

      - CGI::Cookie

      CGI::Cookie::r($r);

      or something like that. Though we have to make into an account that CGI.pm
      might be used in sub-requests, so we should probably make sure that we aren't
      using the wrong global $r.

      and this is the implementation for CGI::Cookie (we need a similar one for
      CGI.pm). I have also suggested to abstract all the mp functionality in a
      separate module e.g., CGI/MP.pm, so we don't have to duplicate and maintain
      several copies of the same code. Loading CGI.pm in CGI::Cookie sounds like a
      bad idea if CGI is not already used elsewhere, because of the bloat.

      package CGI::Cookie;
      ...
      use vars qw($gr); # global $r
      # get/set
      sub r {
      $gr = shift if @_;
      return $gr || Apache->request;
      }
      sub new {
      ...
      if ($MOD_PERL) {
      r()->pool->cleanup_register(\&CGI::Cookie::_reset_globals);
      }
      }
      sub _reset_globals { initialize_globals(); }
      sub initialize_globals {
      $gr = undef;
      }



      __________________________________________________________________
      Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
      http://stason.org/ mod_perl Guide ---> http://perl.apache.org
      mailto:stas@... http://use.perl.org http://apacheweek.com
      http://modperlbook.org http://apache.org http://ticketmaster.com
    • Arshavir Grigorian
      ... In case anyone is curious, it was a Perl bug (#36521) and has now been fixed.
      Message 40 of 40 , Jul 26, 2005
      • 0 Attachment
        Arshavir Grigorian wrote:
        > Hello list,
        >
        > Not sure when this started happening, but at some point calling
        > CGI::Carp::carp() started resulting in deep recursion within
        > CGI::Carp::warn() eventually killing the process. I think the recursion
        > is caused by the following:
        >
        > $main::SIG{__WARN__}=\&CGI::Carp::warn;
        >
        > sub realwarn { CORE::warn(@_); }
        >
        > sub warn {
        > ...
        > return realwarn $message;
        > }
        >
        > Is this a bug in the code or am I reading this wrong?

        In case anyone is curious, it was a Perl bug (#36521) and has now been
        fixed.
      Your message has been successfully submitted and would be delivered to recipients shortly.