Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Using CGI::Ajax and CGI::Application::Plugin::DBH

by trwww (Priest)
on Aug 25, 2009 at 19:25 UTC ( #791165=note: print w/replies, xml ) Need Help??


in reply to Using CGI::Ajax and CGI::Application::Plugin::DBH

Make BUILD_CHART a CGI::App runmode.

UPDATE:

Well I guess its not quite as simple as all that... but probably what I would do would somehow make a bridge between CGI::App and CGI::Ajax, possibly via the CGI::App plugin mechanism.

To get it going quickly, you could probably instantiate your CGI::App subclass in BUILD_CHART:

my $dbh = MyWebApp->new->dbh

Replies are listed 'Best First'.
Re^2: Using CGI::Ajax and CGI::Application::Plugin::DBH
by jrsimmon (Hermit) on Aug 25, 2009 at 21:02 UTC

    The problem is that when called through CGI::Ajax, 'BUILD_CHART' doesn't utilize runmodes. It dynamically builds the XMLHTTP request and, as far as i can tell, is able to bypass the instance script altogether.

    Just getting it working isn't a problem -- I can build up and tear down the connections within 'BUILD_CHART' itself with no problems.

    It occurred to me while talking this over with a coworker that it's likely going to require a port from cgi to mod_perl to achieve the persistent connection in the background -- that is, unless someone has a better suggestion?

      The problem is that when called through CGI::Ajax, 'BUILD_CHART' doesn't utilize runmodes. It dynamically builds the XMLHTTP request and, as far as i can tell, is able to bypass the instance script altogether.

      Sure it does not all work together out of the box. But I've given suggestions as to how to make it work.

      It occurred to me while talking this over with a coworker that it's likely going to require a port from cgi to mod_perl to achieve the persistent connection in the background.

      There is nothing in what you are trying to do that requires this. As I mentioned already, you are going to have to do one of A) modify CGI::App or CGI::Ajax to your liking, B) use the CGI::App plugin system to make a shim for what you need, or C) subclass one or the other or both to get the CGI::App object in to the CGI::Ajax callback.

      Again, at the very least, if you simply call:

      my $dbh = MyApp->new->dbh;

      in the CGI::Ajax callback you should be all set.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://791165]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2019-10-21 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?