[jifty-devel] Re: jifty mod_perl handler
Wolfgang Kinkeldei
wolfgang at kinkeldei.de
Thu Nov 9 16:32:25 EST 2006
Am 09.11.2006 um 11:29 schrieb Agostini yves:
> 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.
You will have to face one problem when using mod_perl: "Jifty" is a
singleton. The "Jifty" Class stores a lot of values in the class --
including the configuration (see the "use vars ..." in Jifty.pm).
Therefore, you will only be able to have _one_ Jifty Object inside
the whole mod_perl environment...
I also figured out one more thing arising from the latest changes.
The "...::Event::..." classes are "require"d on demand with also
results in failures when using mod_perl. The error occurs when an
action is taken that updates a record in the DB.
So I personally think (in the meantime), using FastCGI is more useful
than mod_perl. As the FastCGI processes already are running, the
speed of a single request should almost be the same. Maybe an
additional advantage of FastCGI could be the overall memory
consumption on a heavily used Apache running lots of sites.
Also, when using a test- and a live- environment for the same site,
maybe there could be some interference with mason-generated classes
for the compiled templates (thinking worst-case) -- but I am not sure.
> 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 ?
Regards,
Wolfgang
--
' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x
'( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+||
' > ^ < ' .q<!-- Wolfgang Kinkeldei - mailto:wolfgang at kinkeldei.de -->
More information about the jifty-devel
mailing list