logo       

Re: Patch to implement USE_SINGLETON idea in CAP::TT: msg#00130

Subject: Re: Patch to implement USE_SINGLETON idea in CAP::TT
On Thu, 27 Jan 2005 23:02:23 -0500, Perrin Harkins 
<perrin-rcKlk6LmnZA@xxxxxxxxxxxxxxxx> wrote:
> On Thu, 2005-01-27 at 22:52 -0500, Cees Hek wrote:
> > Instead of configuring the object by
> > calling $self->tt_config(...) you can now provide all the options when
> > you 'use' the module.
> >
> > package My::App;
> >
> > use base qw(CGI::Application);
> > use CGI::Application::Plugin::TT (
> >               TEMPLATE_OPTIONS => {
> >                         POST_CHOMP   => 1,
> >                         FILTERS => {
> >                                      'currency' => sub { sprintf('$
> > %0.2f', @_) },
> >                         },
> >               },
> > );
> 
> As a general rule, I don't like it when modules co-opt import() for
> something that is totally different from importing.  I'd rather see this
> done in a separate method, at least as an option.

I can make the following work just as easily (in fact, that is what is
happening under the hood right now as tt_config is called from the
call to import)..

package My::App;

use CGI::Application::Plugin::TT;

My::App->tt_config(
              TEMPLATE_OPTIONS => {
                        POST_CHOMP   => 1,
                        FILTERS => {
                          'currency' => sub { sprintf('$%0.2f', @_) },
                        },
              },
);

That way tt_config can work as a class method for configuring a
persistent object, or as an object method to configure a one time
object.

> > I've also added a method to change the INCLUDE_PATH dynamically.called
> > tt_include_path (as per Perrin's suggestion).
> 
> Thanks!  Hopefully that will help make more people aware that this is
> allowed with TT, and they can realize some serious performance gains.

Well, I've started using it myself now, although I haven't done any
benchmarking to see what the gains actually are.

Cheers,

-- 
Cees Hek


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe