[cgiapp] Re: CGI::Application::Server bug with regards to $self->query?

Jaldhar H. Vyas jaldhar at braincells.com
Thu Dec 4 11:59:35 EST 2008


On Thu, 4 Dec 2008, Mark Stosberg wrote:

>
>> Actually now that I've looked at it, I think the problem is actually in
>> CGI::Application not ::Server.  The query object is initialized in new()
>> shouldn't this actually happen in run()?
>
> I would say the bug is here, in CGI::Application::Server
>

Well...

> if (!defined blessed $target) {
> 	    return $self->_serve_response($target->new->run);
> } else {
>        # Missing line:
>        $target->cgiapp_get_query;
> 	    return $self->_serve_response($target->run);
> }
>

This still didn't work with the example script in my previous message. 
The same problems were exhibited.


> The calling of cgiapp_get_query *is* delayed until run()... really until the
> first time you call "query()". There is no way to detect you need a fresh query
> object.  The server needs to take care of that.
>

On further investigation, the server provides a query object called $cgi 
which needs to be passed to the CGI::Application object.  You can do this 
in new() with the QUERY parameter but there doesn't seem to be a way to do 
so after the object is created but before it is run.  What I did instead 
was:

            if (!defined blessed $target) {
             return $self->_serve_response($target->new->run);
            } else {
             $target->{__QUERY_OBJ} = $cgi; # <-- works but not ideal
             return $self->_serve_response($target->run);
            }
         }

it is not a good idea to be mucking about with CGI::Application internals 
like that so there ought to be a cgiapp_set_query to use in these 
(admittedly rare) situations.

-- 
Jaldhar H. Vyas <jaldhar at braincells.com>


More information about the cgiapp mailing list