Thursday, January 28, 2010

use Devel::NYTProf with CGI and apache

put these lines in the apache virtualhost config file:

SetEnv NYTPROF "file=/tmp/nytprof.out"
SetEnv PERL5OPT "-d:NYTProf"

the output from Devel::NYTProf will go to /tmp/nytprof.out

Saturday, January 23, 2010

undefined symbol: apreq_handle_apache2

solution from here

symbol lookup error: /usr/lib/perl5/auto/APR/Request/Apache2/ undefined symbol: apreq_handle_apache2

Make sure you load the apreq module in your apache2 config file:

LoadModule apreq_module /usr/lib/apache2/modules/

In debian there is a file in /etc/apache2/mods-available called
apreq.load. Just link that to your
/etc/apache2/mods-enabled directory and restart apache2

HTML::Mason and apache issues

this was copied from somebody else, but I did not keep the reference ...

while atempting to upload files in html::mason the response is only "End of file found":

solution: add this to the vhost configuration file

PerlSetVar MasonArgsMethod mod_perl

explanation: it seems HTML::Mason is using CGI to deal with post/get by default, and when CGI is done with post/get, there is nothing left for apreq to work with; the line tells HTML::Mason to use mod_perl to deal with the args

I18N for HTML::Mason

in the folder where I keep the virtual host data:

locale/ro/LC_MESSAGES/ is where the file goes

drwxrwxr-x 1 emilper www-data 4096 2010-01-22 04:53 apache_conf
drwxrwxr-x 1 emilper www-data 4096 2010-01-22 05:48 htdocs
drwxrwxr-x 1 emilper www-data 4096 2008-07-16 18:37 lib
drwxr-xr-x 1 emilper emilper 4096 2010-01-22 02:33 locale
drwxrwxr-x 1 emilper www-data 4096 2008-07-19 02:13 log
drwxrwxr-x 1 emilper www-data 4096 2010-01-22 04:54 mason

in my Apache VirtualHost config:

PerlSetVar GettextLocalesDir /home/www/mysite/locale/
PerlSetVar GettextDomain messages

in my Mason request class (MasonRequestClass set in apache conf) :

$self->{'i18n'} = Locale::gettext->domain($self->apache_req->dir_config('GettextDomain'));


sub _t {
my ($self, $string) = @_;
return $self->{'i18n'}->get($string);

in my code:

$page_title = $m->_t("String to translate");

As of now, I have difficulties persuading xgettext to extract the strings from autohandlers, .mas files, and .html files. Until I write my own extractor, I add the strings by hand to a "messages.po" file, which I compile to a "" file that can be used by gettext with:

msgfmt messages.po