If I could make a suggestion -- don't depend upon a CGI.pm interface
for form variables.  Abstract it away.  One option would be to use
closures:

my $cgi = new CGI;
my $formvar = sub { $cgi->param(@_) };
my $wc = HTML::Widget::Controller->new(\%config, $formvar);

Or possibly, inside the constructor, do something like:

sub HTML::Widget::Controller::new {
  my $class = shift;
  my $config = shift;
  my $cgi = shift;

  if (ref $cgi and ref $cgi eq 'CGI') {
    my $tmp = $cgi; # not strictly necessary, but it makes it clearer
    $cgi = sub { $tmp->param(@_) };
  }

  ...
}

That way the user can easily give you different sources of formvars
(libapreq, Apache::ASP's hash, plus others not yet public) and yet you
still get the flexibility you need.

I would suggest using a class for this kind of thing, but
realistically it's a bit much to expect users to derive classes just
for something as simple as this.  By supporting the coderef closure
internally, you don't force users to understand what's going on, but
still allow for more advanced users to use different interfaces.  Plus
you remove dependance on a web server.

Chip

Adi Fairbank <[EMAIL PROTECTED]> writes:

> Stephen,
> 
> I read your proposal and I like it a lot.  I will help filling out the
> HTML::Widget::HTML* space (in your package structure suggestion).
> 
> However, I like Gunther's suggestion for a namespace of Widget:: better than
> HTML::Widget::, because it will not be exclusively HTML, but WML, JS10,
> etc.  But either one is fine with me.
> 
> Sounds fun!
> -Adi
> 
> Stephen Adkins wrote:
> > 
> > Hi,
> > 
> > I will step up to write this code. (if it is what I think it is)
> > I have responded to the message by beginning a requirements document.
> > 
> >    http://www.officevision.com/pub/HTML-Widget/
> > 
> > Please read it and send me any comments.

-- 
Chip Turner                   [EMAIL PROTECTED]
                              RHN Web Engineer

Reply via email to