You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Hemond, Steve" <SH...@SMURFIT.com> on 2004/01/26 14:18:23 UTC

Question about handlers

Hi ppl,

I have read the docs on perl.apache.org and I still don't understand
certain points. mod_perl seem to encourage handlers for handling dynamic
website content. I now know to create an handler to automatically add a
header and a footer to any .html called in a certain location. This
forces me to go back to httpd.conf and add the handler setup there, and
restart Apache so the changes will take effect. What if I need more
handlers? What if I need handlers for database transactions, etc?
Editing httpd.conf and restarting Apache everytime seems wierd to me. I
surely don't understand. 

Actually, the only thing I need to do is to add a header/footer to my
webpages. I plan on adding dynamic content based on a database soon.
Couldn't I handle these details in simple .pl files? (Like having a .pm
acting as a library to my website, containing a bunch of well defined
functions).

I browsed the web for some mod_perl example site (with source code so I
can understand how the content is handled) but didn't find anything.

Maybe if you explain me how YOU wrote your website, that'd help. I
really need explanations about handlers too. The more I read the docs,
the more I am confused. 

Thanks for your suggestions and help in advance,

Best regards,

Steve Hemond
Programmeur Analyste / Analyst Programmer
Smurfit-Stone, Ressources Forestieres
La Tuque, P.Q.
Tel.: (819) 676-8100 X2833
shemond@smurfit.com 


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Question about handlers

Posted by Perrin Harkins <pe...@elem.com>.
Hi Steve,

On Mon, 2004-01-26 at 08:18, Hemond, Steve wrote:
> I now know to create an handler to automatically add a
> header and a footer to any .html called in a certain location. This
> forces me to go back to httpd.conf and add the handler setup there, and
> restart Apache so the changes will take effect.

If you explain the approach you are using to add the header and footer,
we can probably suggest a way to make it work automatically for all
files under a certain directory or all files with a certain extension.

> What if I need more
> handlers? What if I need handlers for database transactions, etc?
> Editing httpd.conf and restarting Apache everytime seems wierd to me.

Most people don't mind, since this all happens during development and
restarting only takes a second.  If it bothers you though, there are
various ways to avoid it.  One is to use Apache::Dispatch, which maps
URLs to modules automatically.  Another is to use a system like Mason,
Embperl, Apache::ASP, or Apache::Registry and set it up to handle all
requests for a certain directory or file type.

You may be wondering why it isn't as obvious as something like PHP,
where you just edit the conf file one and then create .php files.  The
answer is that PHP is very limited in terms of the ways you can use it,
while mod_perl allows a much broader set of options and can be
configured in many more ways.

> Couldn't I handle these details in simple .pl files? (Like having a .pm
> acting as a library to my website, containing a bunch of well defined
> functions).

Of course.  Just use Apache::Registry and write your .pl files the way
you would write CGI scripts.  They will work like CGI scripts, but much
faster.

> I browsed the web for some mod_perl example site (with source code so I
> can understand how the content is handled) but didn't find anything.

There are tons of code samples in the documentation on perl.apache.org,
and there are more in the documentation for specific templating
systems.  You can also get one of the mod_perl books, which include lots
of code.

If you have more specific questions, ask away.

- Perrin


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: Question about handlers

Posted by semuel <se...@semuel.co.il>.
Hello There.

Maybe playing with mod_perl handles is too much for your site's needs. Why
won't you try one of the templating systems? 
For example, Mason will let you stay with your html files, and you can add
header/footer for the pages, and won't bother you with restarts.
Link: http://www.masonhq.com/

Semuel.

-----Original Message-----
From: Hemond, Steve
Sent: Monday, January 26, 2004 3:18 PM
 Subject: Question about handlers

Hi ppl,

Actually, the only thing I need to do is to add a header/footer to my
webpages. I plan on adding dynamic content based on a database soon.
Couldn't I handle these details in simple .pl files? (Like having a .pm
acting as a library to my website, containing a bunch of well defined
functions).




-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html