> > $self->append('Message',"$tainted_filename had an error<br>");
>
> Hello Brett,
>
> Would you might sharing how your append() method works? It looks like it
> could be a useful part of an error handling system.
It's not fancy. I'll often have a parameter that collects messages from
the program to report to the user. Since any subroutine reporting doesn't
know if other subroutines have put anything into that variable, I would
face a lot of:
$self->param('Message',$self->param('Message')."Message to go to user");
I have a subclass of CGI::App that all of my apps are a subclass of, so I
just added an append routine to it:
sub append {
my $self = shift;
my $param_name = shift;
my $value = shift;
$self->param($param_name,$self->param($param_name).$value);
}
Thus, the above code becomes:
$self->append('Message',"Message to go to user");
Cleaner looking.
Another feature I've used is one parameter (Template_Data) that holds
values to be passed to my templating system (Template Toolkit). My
application can call $self->export('parameter name'), and when the
template is processed, that param() key/value is passed along to the
template (Or rather, it's added into the Template_Data hash which is
passed to the template). My applications tend to have the templates in
them (For example:
sub Default_Page_Template {
my $self = shift;
my $pagebody = q{
<DO Message/>
This is a template in template toolkit
(With non-standard XML-like tags)
};
return \$pagebody;
}
My run mode will then do something like:
sub Default_Page {
my $self = shift;
#do some processing here
my $pagebody = $self->Default_Page_Template;
return $self->output($pagebody);
}
(output() being a function of my superclass that handles the templating
system)
This does break some of the code/template division, but my shop isn't
large, and it reduces some of the maintainence of multiple files. As long
as I code strict differences between the *_Template routines and the
processing routines, it's no trouble.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]