[cgiapp] [patch] CAP::MessageStack + CAP::FormState

Michael Graham magog at the-wire.com
Tue Oct 20 10:29:43 EDT 2009


> And yes, die_on_bad_params is not good for looking for HTML:T:emplate,
> you're right. We first have to look for it via tmpl_class (which, if
> always setting is our consense), and then evaluate it. The later
> check for die_on_bad_params is only a performance issue, as we don't
> need the check if we don't care about template variable declaratoion.

I'm not worried about a performance issue regarding checking a single
hash value.  That's so tiny that it's not worth worrying about.

However since you bring up performance issues, I will reiterate Jason's
point that if you do have die_on_bad_params set, then every template you
have will be loaded and parsed twice.  In fact, if you are using
FormState and MessageStack together, then every template will be loaded
and parsed *three* times.  THAT is a performance issue.  However, since it
only affects people using die_on_bad_params, I'm not going to get too
worked up about it.


> Btw, HTML::Template::Compiled is HTML::Template derived but exactly
> not the same (e.g. die_on_bad_params and associate is not
> implemented) and should therefore set up another tmpl_class.

The method I'm using for determining whether the templating system
supports the HTML::Template die_on_bad_params feature is by using 'isa':

    sub _template_class_isa_html_template {
        my $self = shift;
        # first check to see if the template class is HTML::Template or one of its
        # relatives, e.g. HTML::Template::Pluggable, HTML::Template::Expr
        
        my $html_tmpl_class = $self->html_tmpl_class;
        if ($html_tmpl_class) {
            eval "require $html_tmpl_class;";
            if (eval { $html_tmpl_class->isa('HTML::Template') }) {
                return 1;
            }
        }
        return;
    }

I think this is the proper way of checking, since it works correctly
for all the HTML::Template related modules I'm aware of:
HTML::Template, HTML::Template::Expr, HTML::Template::Pluggable and
HTML::Template::Compiled.

Note that for HTML::Template::Compiled, it (correctly) returns false,
because HTML::Template::Compiled is not a subclass of HTML::Template.  


Michael


-- 
Michael Graham <magog at the-wire.com>


More information about the cgiapp mailing list