in reply to Re: CGI::Application, Templates, and CSS
in thread CGI::Application, Templates, and CSS
To try and simplify things, I moved all of my database calls into a seperate object that was initialised with my main CGI::Application and set as the db param. This simplified the main portion of my code, but there is still a great deal of runmodes all calling each other.sub show_monkey { my $self = shift; my $db = $self->param('db'); my $q = $self->query(); my $monkey_id = $q->param('monkey_id'); my $ref = $db->select_monkey($monkey_id); unless ( defined($ref) ) { $self->param('error' , "Invalid Monkey ID: $monkey_id in show_monk +ey()"); return $self->show_all_monkies(); } my $tmpl = $self->load_tmpl('show_monkey.tmpl'); $tmpl->param( $ref ); return $tmpl->output(); }
Do you have any tips on how best to structure the runmodes? I seem to have a lot of add_blah1 , edit_blah1 , delete_blah1 runmodes, is there a better way to handle that?
Also while i'm asking questions. I have a couple of CGI::Application objects now, one say Monkey::Gallery and another Monkey::News is there a tidy way to call one of the runmodes of Monkey::News (recent_news) for example that can be passed as a param into my main Monkey::Gallery page?
Anyway, any advice anyone can give me would be greatly appreciated. I've been using perl for years now, but have only really started writing stuff on a scale to start worrying about how tidy and modular it is. (I'm reading Design Patterns so i'm on the ladder).
Many Thanks,
Steve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: CGI::Application, Templates, and CSS
by Ryszard (Priest) on Feb 02, 2002 at 01:52 UTC |