[cgiapp] run mode issues when posting data

Michael De Soto pronet at quarghost.com
Tue Nov 25 18:19:33 EST 2008


Thanks for the quick reply.

On Tue, Nov 25, 2008 at 12:39 PM, Michael Peters <mpeters at plusthree.com> wrote:
> For normal name/value pairs there is no difference between GET and POST
> params when handling them in your application. You can get both from
> $self->query->param(). Something else is wrong with your application.

I see now that there is no difference in C::A's handling of GET and
POST. I wrote a quick bare bones app to prove it.

The app was as follows: two run modes, one with a form and one with
straight HTML. The straight HTML page was the default run mode. I used
Data::Dumper in cgiapp_postrun to dump the application object and see
what was what.

I was able to load the form and post to itself without an issue. The
app used the correct run mode when the form was submitted. Best of
all, the POST params were passed without issue.

So I began adding the pieces of my real app into the test app to see
what and where it breaks. It seems that CAP::Session is the bad guy.
When I dump the application object without CAP::Session, we have param
'__QUERY_OBJ' that contains all the query information. This is the
expected behavior.

When  $app->session_config is called from cgiapp_init, then it appears
that the POST parameters disappear from '__QUERY_OBJ' and are placed
in a application parameter called 'CGI_SESSION_OPTIONS'. I think this
is the root of my problem, though I do not understand it.

I tracked down the issue to the second argument '$app->query':

    $app->session_config(
        CGI_SESSION_OPTIONS => [
            'driver:mysql;serializer:Storable;id:sha256',
            $app->query,
            [...]

I found that if I replaced that argument with undef, the application
reverted back to normal and stored my params in __QUERY_OBJ. Otherwise
the params went into 'CGI_SESSION_OPTIONS'.

So the problem is that I don't understand what that argument is
actually doing. At this point we're probably beyond the scope of this
mailing list, but since you all are seasoned application developers,
I'll ask anyway: what does that argument do and why does it appear to
affect the application object?

I went to the CGI::Session docs for guidance. It's not explicit. So I
don't know. I'm assuming it pre-loads the query into the session. It's
not clear why it (or probably more correctly CAP::Session) would
remove the query parameters from the application object. That doesn't
make sense to me. Can anyone shed some light on it?

Michael De Soto


More information about the cgiapp mailing list