Hi all,

Emailed Randal about this but he wasn't able to shed much light on it.

I've been developing a site using CGI::Prototype and I seem to have stumbled on some strange behavior.

I'm using mod_perl running on Apache 2.0. I have a handler that checks to see if a user is logged in and redirects them if they are not. The handler calls another function that needs a CGI query object to check some cookies. What's happening is that if a CGI object is created before initialize_CGI is called, and a call is made to $self->CGI later in the prototype flow, all the data from a form using the post method is lost. It seems that the call to CGI::_reset_globals() is to blame. I'm wondering what the reason was for putting that there, and if it's really necessary. If I comment out the _reset_globals() call below, the post data is not lost.

Anybody else run into this problem and have an idea of a workaround? Can't use libapreq2 as I can't get it to install on my machine.

package Extranet::Test; use strict; use warnings; use Apache2::Const qw(OK); use base 'CGI::Prototype'; use Data::Dumper; sub handler { my $r = shift; $r->content_type('text/html'); my $q = CGI->new(); print Dumper $q; Extranet::Test->activate; my $x = CGI->new(); print Dumper $x; return OK; } # dummy call to CGI object sub app_enter { my $self = shift; $self->CGI; } sub initialize_CGI { my $self = shift; $self->reflect->addSlot ([qw(CGI FIELD autoload)] => sub { require CGI; CGI::_reset_globals(); CGI->new; }); } sub template { \ ' <form method=post> <input type=text name=foo value=bar> <input type=text name=baz value=bax> <input type=submit> </form> '; } 1;

In reply to CGI::Prototype form data bug by vbjordan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.