[jifty-devel] jifty mod_perl handler

Agostini yves agostini at univ-metz.fr
Thu Nov 9 05:29:48 EST 2006


Le mercredi 01 novembre 2006 à 18:31 +0100, Wolfgang Kinkeldei a écrit :
> Hi,
> 
> On 30.10.2006 um 12:27 Agostini yves wrote:
> [...]
> > - has somebody work on a mod_perl handler ?
> 
> I made a try some time ago, the handler works, but it is really basic  
> and could probably get some improvements...
> You can see my try here:
>    http://wiki.kinkeldei-net.de/bin/view/Jifty/JiftyAndApache
> 
> 

hi,

I try to improve your handler to be used in virtualhost, but it doesn't
work and results are so strange that I think we go on wrong way.

here my code it's a mix of my usual mason handler and your jifty handler
it could be used in apache with this conf :
----
<VirtualHost test.univ-metz.fr>
  ServerName test.univ-metz.fr
  DocumentRoot /var/www/YvesTestApp/share/web/templates

PerlSetVar site jiftytest

  <Directory /var/www/YvesTestApp/share/web/templates>
    SetHandler perl-script
    PerlHandler jiftyhandler
    Options Indexes Includes FollowSymLinks
    AllowOverride All
 </Directory>
...
-----

#!/usr/bin/perl
# handler virtual host
#   
package jiftyhandler;

use strict;
    
use Jifty::Everything;
use Apache::Constants qw(:common);
use CGI qw(:standard);
    
my (%jp %jh %jc); ## I tried globals 

use lib
qw(/home/agostini/YvesTestApp/lib /home/agostini/YvesTestApp2/lib);

BEGIN {
%jp = ( 
    'jiftytest' => '/home/agostini/YvesTestApp/',
    'jifty2' => '/home/agostini/YvesTestApp2/'
);


 foreach my $site (qw(jiftytest jifty2)) { #### I tried here to use keys
    chdir($jp{$site});
    Jifty->new();
    $jh{$site}=Jifty->handler;
    $jc{$site}=Jifty->config;
  }
}

sub handler
{
    my ($r) = @_;

    $r->no_cache(1);
    
    my $site = $r->dir_config('site');

    $ENV{PATH_INFO} = $ENV{REQUEST_URI};
    chdir($jp{$site});

   if ($jh{$site}) { ## classloader for plugins are lost in INC
    for my $plugin (@{$jc{$site}->framework('Plugins')}) {
        my $class = "Jifty::Plugin::".(keys %{$plugin})[0];
        my %options = %{ $plugin->{(keys %{$plugin})[0]} };
        $class->new(%options);
    }
   }

    my $cgi = CGI->new();
        $jh{$site}->handle_request( cgi => $cgi );

    return OK;
}
return 1;
----------

If you test you will see that works for one site but on I put a second
one, results will be totally strange, maybe a pb with chdir ?

do you have some better ideas ?


-- 
---------------------------------------------------------------
AGOSTINI Yves             CRI - Université Paul Verlaine - Metz
agostini at univ-metz.fr     http://www.crium.univ-metz.fr
tel: 03 87 31 52 63       fax: 03 87 31 53 33



More information about the jifty-devel mailing list