Its core idea is the "stay on this page or go to another" mechanism. This is directly in opposition to POST-redirect-GET and therefore to good HTTP style. I didn’t have to fight CGIP to do things properly, but I had to ignore its offerings and manually devise everything I needed.
sub activate { my $self = shift; eval { $self->prototype_enter; $self->app_enter; my $this_page = $self->dispatch; $this_page->control_enter; $this_page->respond_enter; my $next_page = $this_page->respond; ## STAY OR GO! $this_page->respond_leave; if ($this_page ne $next_page) { $this_page->control_leave; $next_page->control_enter; } $next_page->render_enter; $next_page->render; $next_page->render_leave; $next_page->control_leave; $self->app_leave; $self->prototype_leave; }; $self->error($@) if $@; # failed something, go to safe mode }
What the webapp would do is store the POSTed data in the session stash and then issue a redirect to the same URL but via a GET, and most likely the GET would retrieve the session data and say "thank you for registering" or offer to confirm the entered data.
But I think the argument is that the GET form of /register_user could be used to present user registration data at many times based on query string data and other things. And so have a well-formed URL API to that rendering functionality is important. And if one resorted to functions, one might not separate the idea of storing a user versus displaying the results of such storage.
sub respond { my $self = shift; my $results = Data::FormValidator->check( $self->CGI, $dfv_profile ) +; my $response_page; if ( $results->has_missing() || $results->has_invalid() ) { $response_page = 'Gimble::Page::Signup::Redo'; eval "require $response_page"; $response_page->reflect->addSlots( results => $results ); } else { $response_page = $self; } return $response_page; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Prototype criticism 1 - cannot use POST-redirect-GET paradigm
by Jenda (Abbot) on Dec 19, 2008 at 22:45 UTC | |
|
Re: CGI::Prototype criticism 1 - cannot use POST-redirect-GET paradigm
by jeffa (Bishop) on Dec 19, 2008 at 17:01 UTC | |
|
Re: CGI::Prototype criticism 1 - cannot use POST-redirect-GET paradigm
by zby (Vicar) on Dec 19, 2008 at 14:56 UTC | |
by merlyn (Sage) on Dec 19, 2008 at 16:23 UTC | |
by zby (Vicar) on Dec 19, 2008 at 16:29 UTC | |
by Anonymous Monk on Dec 19, 2008 at 16:27 UTC |