From: Kai A. <kai...@gm...> - 2005-10-12 06:41:55
|
Hello, I copied the My/App test application from the CGI-Prototype distribution, and added a app.cgi like: use strict; use warnings; use lib qw( /real/path/here ); use My::App; My::App->activate; ---- Now, directing the browser to the application brings up the welcome page, and the source of the page seems ok, form, action, fields and submit-button and all. But filling out the form and submitting it, only yields the same page. The only way to get to the thanks-page is to add the parameters into the url, like http:://localhost/app.cgi?first=3Djohn&last=3Ddoe -> then I get the nice thank-you-page. I use this under a recent Cygwin installation, Perl 5.8.7, and lighthttpd I obviously miss something fundamental here, but I can't figure it out, can anyone point me in the right direction? Kai |
From: Terrence B. <met...@gm...> - 2005-10-12 21:44:06
|
On 10/11/05, Kai Andresen <kai...@gm...> wrote: > Hello, Hi Kai! > > > I copied the My/App test application from the CGI-Prototype > distribution, There's a fully functioning CGI::Prototype app here: http://www.metaperl.org/Guestbook You can download the tarfile and look through it. I can explain it to you step-by-step if you have questions. > and added a app.cgi like: use strict; use warnings; use lib qw( > /real/path/here ); > > use My::App; > My::App->activate; > > ---- > Now, directing the browser to the application brings up the welcome > page, and the source of the page seems ok, form, action, fields and > submit-button and all. Cool... > > > But filling out the form and submitting it, only yields the same page. What did the FORM action attribute action have? > > The only way to get to the thanks-page is to add the parameters into > the url, like http:://localhost/app.cgi?first=3Djohn&last=3Ddoe -> then > I get the nice thank-you-page. Cool... > > > I use this under a recent Cygwin installation, Perl 5.8.7, and lighthttpd > > I obviously miss something fundamental here, but I can't figure it > out, can anyone point me in the right direction? Yes, I think what you are missing is the concept of dispatch. If you look at the activate method in package CGI::Prototype (the easiest way to learn CGIP is to look at the source code), it calls dispatch early on in the activate method. The default dispatch method looks like this: sub dispatch { my $self =3D shift; return $self;=09=09# do nothing, stay here } And so the same page object returning itself is no surprise. In fact, unless you subclass the default dispatch method and specializing it to do certain things with a certain query string parameter (such as rm for runmode), you should never get a different page. If you dont want to handle dispatch yourself, you can use Aristotle's CGI::Prototype::PathInfo, which you can get here: http://prdownloads.sourceforge.net/cgi-prototype/PathInfo.pm?download The dispatch logic is documented in the code. I've also uploaded it to our Sourceforge CVS project but there is a 5-hour delay between anonymous and developer access to cvs updates. |
From: Kai A. <kai...@gm...> - 2005-10-12 16:40:38
|
Hi Terrence, first let me thank you for your time > > There's a fully functioning CGI::Prototype app here: > > http://www.metaperl.org/Guestbook I have already looked at it earlier, and it's nice - I really did not think I had any problems understanding the logic or the relationship between the files. > > and added a app.cgi like: : > > But filling out the form and submitting it, only yields the same page. > > What did the FORM action attribute action have? it has action=3D"http://localhost/test/app.cgi" as appropriate, and method= =3D"post" Also I forgot to mention that the page source validates (i.e. the form is closed). > Yes, I think what you are missing is the concept of dispatch. If you look > at the activate method in package CGI::Prototype (the easiest way to lear= n > CGIP is to look at the source code), it calls dispatch early on in the > activate method. The default dispatch method looks like this: > > sub dispatch { > my $self =3D shift; > return $self; # do nothing, stay here > } No, -well dispatch might be a better place than render_enter for what I know, but the dispatch actually does happen. The problem seems to be that when posted, the params are not seen serverside? app.cgi only uses My/App.pm which extends CGIPH, which defaults to call welcome.pm welcome.pm does dispatch using render_enter where control is transferred to thanks.pm only if both params first and last is available, but that only happens when I set those params in the url.=20 I still don't get why...?? Kai |
From: <me...@st...> - 2005-10-13 12:04:45
|
>>>>> "Kai" == Kai Andresen <kai...@gm...> writes: Kai> I copied the My/App test application from the CGI-Prototype Kai> distribution, and added a app.cgi like: Kai> use strict; Kai> use warnings; Kai> use lib qw( /real/path/here ); Kai> use My::App; Kai> My::App->activate; There's no dispatcher in the TestApp. Inheriting the "return $self" from the base class means that you'll stay forever in the "My::App" state, meaning you'll get the "intentionally left blank" message forever. For a better "tiny" app, see my Linux Magazine articles (google site:stonehenge.com CGI::Prototype for the location). -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <me...@st...> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! |
From: Terrence B. <met...@gm...> - 2005-10-13 12:24:58
|
On 13 Oct 2005 04:58:39 -0700, Randal L. Schwartz <me...@st...> w= rote: > > For a better "tiny" app, see my Linux Magazine articles (google > site:stonehenge.com CGI::Prototype for the location). That location is: http://www.stonehenge.com/merlyn/LinuxMag/col70.html and also 7[12].html |
From: A. P. <pag...@gm...> - 2005-10-13 17:29:51
|
* Randal L. Schwartz <me...@st...> [2005-10-13 14:10]: > For a better "tiny" app, see my Linux Magazine articles (google > site:stonehenge.com CGI::Prototype for the location). Randal: just point people at http://cgi-prototype.sf.net/ – there are links to those articles in the Resources section. Terrence: would you please `chmod -R g+w *` the web site? You have created a directory and a bunch of files that I can’t do anything with because they only have owner write permission. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/> |