Choice of the module
The module - shablonizator working under mod_perl, is powerful "cursor" for sites of any complexity. That he began obrabotchikom to the stage of search responsible for generation of a content of page, it is necessary to define{determine} it{him} in adjustments Apache as PerlHandler. It will allow to make patterns (further components) started, and itself obrabotchik will be caused imperceptibly (by analogy with PHP, JSP and ASP) at each reference{manipulation} to the web-server.
The choice of the author has fallen on HTML:: Mason. His{its} opportunities are rather wide, he allows to mix code Perl with HTML and to make changes in obrabotchik, and also is fine integrated with mod_perl.
The idea of a spelling of all code of a site mixed up with HTML also has a number{line} of lacks. Mason allows to reach{achieve} the compromise, giving an opportunity of storage of the basic code in modules (classes). Thus support of the project becomes simpler, and use OOP favorably affects scalability. One more plus of such organization - an opportunity of repeated application of a code in any projects on Perl, including using interface CGI. Further in clause{article} basic opportunities HTML:: Mason will be considered and the example of the small site created on this "cursor" is resulted.
Installation HTML:: Mason
To take the module it is possible with CPAN or with www.masonhq.com. Any interested person can participate in development and offer the variant of additions.
Process of installation is similar to usual modules. Therefore we shall pass to adjustment of a file of configuration Apache. The author used the operational system FreeBSD, therefore the resulted examples of ways to files are characteristic for UNIX-systems. The first, that it is necessary to make - to add a line:
PerlModule HTML:: Mason:: ApacheHandler
It is better for making in httpd.conf, instead of in .htaccess as in this case loading of the module will take place at start of the web-server, in basic process Apache, and all generated processes will use divided{shared} memory. It will allow to spend more economically memory (Mason - not the smallest module), and also it is essential to reduce time of loading of a component at the first reference{manipulation}. Otherwise Mason it will be loaded by each process separately.
Further it is necessary to add in a configuration file two variables:
PerlSetVar MasonCompRoot/usr/local/www/data
PerlSetVar MasonDataDir/usr/local/www/mason
The first variable defines{determines} root directory of components. The second - a directory of accommodation of service files. At first start Mason creates there some directories. Here there are also transformed components and kehshirovannye the data.
Now it are necessary to register khehndler. We shall agree, that expansion of components will be .html. We shall adjust Apache so that the files which are distinct from *.html, *.txt and files without expansions, were not processed HTML:: Mason:
<FilesMatch " (.html |.txt | [^]. +) $ ">
SetHandler perl-script
PerlHandler HTML:: Mason
</FilesMatch>

|