Perl Template::DBI

Packaging for OpenSuse

This package is required by perl-A2E

1 Situation

We have packaged the module as compressed tar, source rpm and object rpm package, based on perl-Template-DBI.spec, for the a2e opensuse public repository.

2 Issues during building

2.1 Build Requirement Template Toolkit

Can't locate Template.pm in @INC (@INC contains: ./lib ../lib /usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at Makefile.PL line 9.

although Template.pm is definitely found in this path at

-r--r--r-- 1 root root 24510 2007-04-27 
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/Template.pm

This was overcome by adding

BuildRequires: perl-Template-Toolkit

Of course it is also a runtime requirement.

2.2 UTF8 Patch

Perl still handles Unicode encoding in a very unsatisfactory manner: every package must be made explicitely aware that we are not intending to support US English only. We do this by putting a few ugly lines of code into DBI.pm

use Encode qw(_utf8_on)
_utf8_on $data->{$_} for keys %$data

and creating a patch from this according to the rule specified in our Makefile.

Hopefully these quick & dirty changes can help us patiently wait for a Perl 6.0 that wholeheartedly supports Unicode (so that any package will be Unicode-aware by default or as soon as a certain switch/pragma is used by the application).

Before resorting to this patch solution, we tried to set all the Unicode switches on in the applications, also on the Perl commandline with

#!/usr/bin/perl -CSDA

but to no no avail.

3 Issues during Use

3.1 Reuse existing database connection?

The manual says

If you already have a database handle then you can instruct the plugin to reuse it by passing it as the ‘dbh’ parameter.

[* DBI.connect( dbh = my_dbh_ref ) *]

but doesn’t conretise my_dbh_ref. What could be an example of my_dbh_ref?

?

Upon testing this, I really found that by rewriting mlht so that it passes the database handle into a template variable mlht_dbh,

$m->{tmplvars}->{mlht_dbh} = $m->{db}
[...]
$m->{template}->process($m->fh('i'), 
$m->{tmplvars}, undef, binmode => ':utf8') or die 
$m->{template}->error()

I can then reuse that handle as follows:

[* USE DBI(dbh = mlht_dbh) *]

This makes a big difference. Now I do not have to transport any passwords in visible places. Neither as cleartext in a file nor a values of template variables that any knowledgable user could print out. The only value that I carry in a template variable is the ready database connection handle mlht_dbh, which Template/Perl renders as follows:

DBI::db=HASH(0x8a11d48)

3.2 Complex SQL Select Commands

Something like

select taktg || '@' || supktg as tasup, taktgrem, 
sum(tabetrag) as tasum from sskmta natural join 
tadok natural join taktg where tadatum >= 
'2007-01-01' and tadatum 
<= '2007-12-31' group by taktg, supktg, taktgrem'

will work. No issue here. Take care to name each field with ‘as’ and to use the quotes correctly.

4 Resources

5 Chronology

  • dat: 2008-05-02; prs: phm: apache created this directory
[ ADP | Packages | perl | perl-HTML-Summary | perl-WWW-Robot | perl-WWW-Sitemap | perl-Search-Sitemap | perl-Unicode-EastAsianWidth | perl-Term-ReadLine-Gnu | perl-BSD-Resource | perl-Net-Ping | perl-IO | perl-Data-Dumper | perl-Template-Multilingual | perl-Unix-ConfigFile | perl-DateTime-Format-W3CDTF | perl-DateTime-TimeZone | perl-List-MoreUtils | perl-DateTime-Locale | perl-DateTime | perl-Error | perl-Class-Inner | perl-Devel-Symdump | perl-Email-Filter | perl-Class-ErrorHandler | perl-Convert-ASN1 | perl-Convert-PEM | perl-Crypt-DES | perl-Crypt-DES_EDE3 | perl-Crypt-CAST5_PP | perl-Crypt-CAST5 | perl-Convert-ASCII-Armour | perl-Crypt-RIPEMD160 | perl-Tie-EncryptedHash | perl-Crypt-Random | perl-Crypt-Primes | perl-Class-Loader | perl-Crypt-Rijndael | perl-Crypt-CBC | perl-Crypt-Twofish | perl-Crypt-Blowfish | perl-Module-Install | perl-Crypt-IDEA | perl-Crypt-DSA | perl-Crypt-RSA | perl-Data-Buffer | perl-ExtUtils-AutoInstall | perl-Math-Pari | perl-MIME-Types | perl-Return-Value | perl-Test-Class | perl-Test-Unit | perl-DateTime-Format-Mail | perl-Cache-Cache | perl-HTML-Parser | perl-Html-Mason | perl-Test-Simple | perl-Devel-StackTrace | perl-Scalar-Util | perl-Class-Data-Inheritable | perl-Class-Container | perl-Exception-Class | perl-Params-Validate | perl-XML-RSS | perl-OLE-Storage_Lite | perl-OLE-Storage | perl-Spreadsheet-ParseExcel | perl-IO-Stty | perl-Crypt-OpenPGP | perl-IO-Tty | perl-Psh | perl-Template-DBI| Sendmail| perl-Mail-Box| Sendmail| perl-Email-Simple| perl-Email-Abstract| AppConfig| Expect ]
Valid XHTML 1.0! Valid CSS! deplate
http://a2e.de/adv/pak/perl-Template-DBI
© 2008-05-02 Hartmut PILCH