Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: RFC: Class::CGI

by leriksen (Curate)
on Apr 07, 2006 at 23:50 UTC ( #541988=note: print w/ replies, xml ) Need Help??


in reply to RFC: Class::CGI

I was wondering if there was any benefit in this kind of interface

use Class::CGI handlers => { customer => 'Class::CGI::Customer', email => 'Email::Loader' }; my $cgi = Class::CGI->new; my $customer = $cgi->customer(); # dispatch to C::C::C my $email = $cgi->email(); # dispatch to E::L my @sports = $cgi->param('sports'); # as per usual # validate email $customer->email($email); $customer->save;

Surmising, if you've declared the handlers, perhaps you can construct things so that these handlers become methods in this instance of Class::CGI. You just have to come up with a way to make sure the methods are only in this scope of the "use Class::CGI" declaration. I

...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann


Comment on Re: RFC: Class::CGI
Download Code
Re^2: RFC: Class::CGI
by Ovid (Cardinal) on Apr 08, 2006 at 00:05 UTC

    That changes the design dramatically since I would then have to delegate to the real CGI::Simple object lest someone have paremeters named "keywords", "param" or "upload" and innapropriately overloading things. Still, it might be a cleaner interface. I would simply have to find an easier way for folks to get at the underlying CGI object, if necessary. I would hate arbitrarily outlawing certain parameters because they're "reserved" methods. Some folks wouldn't be able to use the code that way since it would be tough to integrate with an existing site which used the reserved parameter names.

    I could do something like this:

    use CGI; use Class::CGI handlers => { customer => 'Class::CGI::Customer' }; my $cgi = Class::CGI->new( cgi => CGI->new );

    That would also have the advantage of allowing folks to use any class which implements the required CGI methods (just param(), at this time). It has the disadvantage of forcing them to explicitly load in the other module and I was hoping to do away with that. I could be done implicitly, but that brings back the problems mentioned in the first paragraph. I'll have to think about this.

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://541988]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-09-24 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (246 votes), past polls