modperl questions
hello world, I have been eavesdropping on this list for a while and have enjoyed the general discussion. I have been working on a perl based application for about a year now, and am longing to migrate to mod_perl. I build a few simple commercial sites with mod perl previously and loved it. My current project is slightly more complex as there are multiple levels of application and management. It is vanilla cgi at the moment, for ease of dev and it isn't easy to find skilled perl craftsman here in S.A. I have written some tools for migrating the module tree to mod_perl, but have some questions nagging before I go ahead. Here goes, There is a central database of client information which is queried for application specific data: databse name, ht root, cgi-bin (each application instance runs its own cgi-bin so that the application can be customised to the clients needs) etc. Not all the cgi will migrate to mod_perl for customisation maintenance needs but the code engine should/must. question one There is a need to add new client profiles to the centralised database, which create new application filesystems, new database structures and CGI trees. Thus a new profile can be created and activated with the push of a few buttons, but, as it stands, the cgi structure looks like this https://www.foo.co.za/cgi-bin/client1/index.pl https://www.foo.co.za/cgi-bin/client2/index.pl it would be better if it was https://www.foo.co.za/client1 https://www.foo.co.za/client2 just using normal aliasing, but now the problem, -- how to add new aliases to httpd.conf or ./conf/clients.pl without having to restart apache ?? - i have found no linear solution, but there may be a craftier solution, even if some reworking needs to be done second question: Now that we have multiple application and databse instances running concurrently, how do we ensure that filehandle and Apache::DBI symbols are reliably encapsulated in their own namespsaces, all running off the same codebase ? I just feel i need a bit of affirmation that this is 100% before i start this arduous journey Thanks Alastair Stuart Systems Developer Quirk R D 3rd Floor Armoury Building Buchanan Square 160 Sir Lowry Road Cape Town 7925 eml: [EMAIL PROTECTED] land: +27 21 462 7353 fax: +27 21 462 7354 http://www.quirk.co.za
Re: modperl questions
- Original Message - From: Alastair Stuart [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 18, 2001 3:38 PM Subject: modperl questions [snip] -- how to add new aliases to httpd.conf or ./conf/clients.pl without having to restart apache ?? Why not use a perl handler? Put all the logic in perl libraries and not perl scripts. Make 1 perl package for communicatio between apache and the perl library. Then define a location in the apache handler once: Location /Client SetHandler perl-script PerlHandler FOO::Client /Location In the package FOO::Client make a subroutine named handler. use FOO::SomeApplication; sub handler { my $r = shift; my ($command, $params) = split (, $r-args, 2); my %params = map {s/\+/ /g; s/%([0-9a-zA-Z]{2})/chr(hex($1))/eg; $_} map {split /=|$/, $_, 2} split //, $r-args(); $params = $params if $params; my $client = substr ($r-path_info(),1); # do your stuff here } Then you can use UR's like: https://www.foo.co.za/Client/johnson https://www.foo.co.za/Client/Pete The URL will not point to a file, but to a resource. Th eclient name will be in $client in the handler shown above. Hope this puts you in the right direction. second question: Now that we have multiple application and database instances running concurrently, how do we ensure that filehandle and Apache::DBI symbols are reliably encapsulated in their own namespsaces, all running off the same codebase ? See above You can use different perl packages for each Location So you can use multiple applications. You can even set HTTP authentication for each Location... This way you might be able to use you existing perl packages without migrating them. Hope this puts you in the right direction. Maarten.
Re: modperl questions
as it stands, the cgi structure looks like this https://www.foo.co.za/cgi-bin/client1/index.pl https://www.foo.co.za/cgi-bin/client2/index.pl it would be better if it was https://www.foo.co.za/client1 https://www.foo.co.za/client2 You can just use this in your httpd.conf: DirectoryIndex index.pl Now that we have multiple application and databse instances running concurrently, how do we ensure that filehandle and Apache::DBI symbols are reliably encapsulated in their own namespsaces, all running off the same codebase ? Apache::DBI will only give you back a cached connection if your connecion parameters (user, login, etc.) are exactly the same. If different clients connect to different databases, this should be fine. You won't accidentally get the wrong one. As for filehandles, I suggest you use lexically scoped ones if possible. - Perrin
Re: modperl questions
On Tue, 18 Dec 2001, Alastair Stuart wrote: question one There is a need to add new client profiles to the centralised database, which create new application filesystems, new database structures and CGI trees. Thus a new profile can be created and activated with the push of a few buttons, but, as it stands, the cgi structure looks like this https://www.foo.co.za/cgi-bin/client1/index.pl https://www.foo.co.za/cgi-bin/client2/index.pl it would be better if it was https://www.foo.co.za/client1 https://www.foo.co.za/client2 just using normal aliasing, but now the problem, -- how to add new aliases to httpd.conf or ./conf/clients.pl without having to restart apache ?? I've used RewriteEngine on RewriteRule ^/bin/([^/]+)/(.*) /usr/local/systems/work/$2 and then sub db { # get the $db from the url my @split_line = split /\//, $ENV{REQUEST_URI} ; my $db = $split_line[2] ; return $db ; } and the $db I use to get a db handle That's how I do it but my application leans towards cgi than mod_perl. I have 4 different types of systems using the same codebase. Alltogether 13 systems. Works well. regards Scott - i have found no linear solution, but there may be a craftier solution, even if some reworking needs to be done second question: Now that we have multiple application and databse instances running concurrently, how do we ensure that filehandle and Apache::DBI symbols are reliably encapsulated in their own namespsaces, all running off the same codebase ? I just feel i need a bit of affirmation that this is 100% before i start this arduous journey Thanks Alastair Stuart Systems Developer Quirk R D 3rd Floor Armoury Building Buchanan Square 160 Sir Lowry Road Cape Town 7925 eml: [EMAIL PROTECTED] land: +27 21 462 7353 fax: +27 21 462 7354 http://www.quirk.co.za