Re: [cgiapp] testing the new CAD::PSGI version

2011-05-19 Thread Ron Savage
Hi Mark

Another attempt. More below.

On Thu, 2011-05-19 at 11:26 +1000, Ron Savage wrote:
> Hi Mark
> 
> Doesn't work for me.
> 
> I assume it's due to the exact combination of modules used and their
> parentage.
> 
> (1) 1 line change to Local::Application::Controller:
> 
> package Local::Application::Controller;
> 
> #Patch#use parent 'CGI::Application';
> use parent 'CGI::Application::Dispatch::PSGI';
> use strict;
> use warnings;
> ...
> 
> (2) 2 line change to app.psgi:
> 
> #!/usr/bin/env perl
> #
> # Run with:
> # starman -l 127.0.0.1:5002 --workers 1 httpd/cgi-bin/local/app.psgi &
> # or, for more debug output:
> # plackup -l 127.0.0.1:5002 httpd/cgi-bin/local/app.psgi &
> 
> use strict;
> use warnings;
> 
> #Patch#use CGI::Application::Dispatch::PSGI;
> use Local::Application::Controller;
> 
> use Plack::Builder;
> 
> # -
> 
> #Patch#my($app) = CGI::Application::Dispatch -> as_psgi
> my($app) = Local::Application::Controller -> as_psgi
> (
>   prefix => 'Local::Application::Controller',
>   table  =>
>   [
>   ''  => {app => 'Initialize', rm => 'display'},
>   ':app'  => {rm => 'display'},
>   ':app/:rm/:id?' => {},
>   ],
> );
> 
> builder
> {
>   enable "Plack::Middleware::Static",
>   path => qr!^/(assets|favicon|yui)/!,
>   root => '/dev/shm/html';
>   $app;
> };
> 
> (3) The error:
> 
> [Dispatch] ERROR: Unknown error: Can't locate object method "new" via
> package "Local::Application::Controller::Initialize"
> at 
> /home/ron/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/CGI/Application/Dispatch/PSGI.pm
>  line 455.
> 
> This'll be because CGI::Application itself is not pulled in.

(4) 1 line change to Local::Application::Controller (multiple
inheritance):

package Local::Application::Controller;

#Patch#use parent 'CGI::Application';
use parent qw/CGI Application CGI::Application::Dispatch::PSGI/;
use strict;
use warnings;
...

(5) The error:

[Dispatch] ERROR: Unknown error: Can't locate object method
"run_as_psgi" via package "Local::Application::Controller::Initialize"
at 
/home/ron/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/CGI/Application/Dispatch/PSGI.pm
 line 465.

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] testing the new CAD::PSGI version

2011-05-18 Thread Ron Savage
Hi Mark

Doesn't work for me.

I assume it's due to the exact combination of modules used and their
parentage.

(1) 1 line change to Local::Application::Controller:

package Local::Application::Controller;

#Patch#use parent 'CGI::Application';
use parent 'CGI::Application::Dispatch::PSGI';
use strict;
use warnings;
...

(2) 2 line change to app.psgi:

#!/usr/bin/env perl
#
# Run with:
# starman -l 127.0.0.1:5002 --workers 1 httpd/cgi-bin/local/app.psgi &
# or, for more debug output:
# plackup -l 127.0.0.1:5002 httpd/cgi-bin/local/app.psgi &

use strict;
use warnings;

#Patch#use CGI::Application::Dispatch::PSGI;
use Local::Application::Controller;

use Plack::Builder;

# -

#Patch#my($app) = CGI::Application::Dispatch -> as_psgi
my($app) = Local::Application::Controller -> as_psgi
(
prefix => 'Local::Application::Controller',
table  =>
[
''  => {app => 'Initialize', rm => 'display'},
':app'  => {rm => 'display'},
':app/:rm/:id?' => {},
],
);

builder
{
enable "Plack::Middleware::Static",
path => qr!^/(assets|favicon|yui)/!,
root => '/dev/shm/html';
$app;
};

(3) The error:

[Dispatch] ERROR: Unknown error: Can't locate object method "new" via
package "Local::Application::Controller::Initialize"
at 
/home/ron/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/CGI/Application/Dispatch/PSGI.pm
 line 455.

This'll be because CGI::Application itself is not pulled in.

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] testing the new CAD::PSGI version

2011-05-16 Thread Ron Savage
Hi Mark

On Mon, 2011-05-16 at 08:34 -0400, Mark Stosberg wrote:
> > CGI::Application::Dispatch::PSGI gives any CGI script using CGI::App
> > access to PSGI's amazing capabilities. It's what I use for every CGI
> > script, nowadays.
> 
> Ron,
> 
> Could you test the Github version of CAD::PSGI if you haven't already?
> As part of re-implementing it better, it should be a little faster, and
> the calling syntax did have to change slightly.

I wasn't watching Github. I'll do that. But today (it's 7:55 am) I'm
having reverse cycle air conditioning installed, meaning they have to
tunnel thru the double brick lounge wall to install it.

Maybe tomorrow.

> Before:
> 
>  use Your::Application::Dispatch;
>  use CGI::Application::Dispatch::PSGI;
>  Your::Application::Dispatch->as_psgi;
> 
> After:
> 
>  use Your::Application::Dispatch;
>  Your::Application::Dispatch->as_psgi;
> 
>  ### In Your::Application::Dispatch;
>  package Your::Application::Dispatch;
>  use base 'CGI::Application::Dispatch::PSGI';
> 
> 
> The full Synopsis is below. Here's the the link to the source:
> 
> https://github.com/markstos/CGI--Application--Dispatch/blob/psgi-support/lib/CGI/Application/Dispatch/PSGI.pm
> 
> The current maintainer of that namespace has give me authority to upload
> this replacement version there, which has a more efficient implementation.
> 
> 
> ##
> 
> =head1 SYNOPSIS
> 
> =head2 Out of Box
> 
> Under mod_perl:
> 
>   # change "Apache1" to "Apache2" as needed.
> 
>   
>   SetHandler perl-script
>   PerlHandler Plack::Handler::Apache1
>   PerlSetVar psgi_app /path/to/app.psgi
>   
> 
>   
>   use Plack::Handler::Apache1;
>   Plack::Handler::Apache1->preload("/path/to/app.psgi");
>   
> 
> Under CGI:
> 
> This would be the instance script for your application, such
> as /cgi-bin/dispatch.cgi:
> 
> ### in your dispatch.psgi:
> # ( in a persistent environment, use FindBin::Real instead. )
> use FindBin 'Bin';
> use lib "$Bin/../perllib';
> use Your::Application::Dispatch;
> Your::Application::Dispatch->as_psgi;
> 
> ### In Your::Application::Dispatch;
> package Your::Application::Dispatch;
> use base 'CGI::Application::Dispatch::PSGI';
> 
> 
> =head2 With a dispatch table
> 
> package MyApp::Dispatch;
> use base 'CGI::Application::Dispatch::PSGI';
> 
> sub dispatch_args {
> return {
> prefix  => 'MyApp',
> table   => [
> ''=> { app => 'Welcome', rm => 'start' },
> ':app/:rm'=> { },
> 'admin/:app/:rm'  => { prefix   => 'MyApp::Admin' },
> ],
> };
> }
> 
> 
> #  CGI::Application community mailing list  
> ####
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
> ####
> ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
> ##  Wiki:  http://cgiapp.erlbaum.net/ ##
> ####
> 
> 
> 

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] testing the new CAD::PSGI version

2011-05-16 Thread Mark Stosberg

> CGI::Application::Dispatch::PSGI gives any CGI script using CGI::App
> access to PSGI's amazing capabilities. It's what I use for every CGI
> script, nowadays.

Ron,

Could you test the Github version of CAD::PSGI if you haven't already?
As part of re-implementing it better, it should be a little faster, and
the calling syntax did have to change slightly.

Before:

 use Your::Application::Dispatch;
 use CGI::Application::Dispatch::PSGI;
 Your::Application::Dispatch->as_psgi;

After:

 use Your::Application::Dispatch;
 Your::Application::Dispatch->as_psgi;

 ### In Your::Application::Dispatch;
 package Your::Application::Dispatch;
 use base 'CGI::Application::Dispatch::PSGI';


The full Synopsis is below. Here's the the link to the source:

https://github.com/markstos/CGI--Application--Dispatch/blob/psgi-support/lib/CGI/Application/Dispatch/PSGI.pm

The current maintainer of that namespace has give me authority to upload
this replacement version there, which has a more efficient implementation.


##

=head1 SYNOPSIS

=head2 Out of Box

Under mod_perl:

  # change "Apache1" to "Apache2" as needed.

  
  SetHandler perl-script
  PerlHandler Plack::Handler::Apache1
  PerlSetVar psgi_app /path/to/app.psgi
  

  
  use Plack::Handler::Apache1;
  Plack::Handler::Apache1->preload("/path/to/app.psgi");
  

Under CGI:

This would be the instance script for your application, such
as /cgi-bin/dispatch.cgi:

### in your dispatch.psgi:
# ( in a persistent environment, use FindBin::Real instead. )
use FindBin 'Bin';
use lib "$Bin/../perllib';
use Your::Application::Dispatch;
Your::Application::Dispatch->as_psgi;

### In Your::Application::Dispatch;
package Your::Application::Dispatch;
use base 'CGI::Application::Dispatch::PSGI';


=head2 With a dispatch table

package MyApp::Dispatch;
use base 'CGI::Application::Dispatch::PSGI';

sub dispatch_args {
return {
prefix  => 'MyApp',
table   => [
''=> { app => 'Welcome', rm => 'start' },
':app/:rm'=> { },
'admin/:app/:rm'  => { prefix   => 'MyApp::Admin' },
],
};
}


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####