Re: HTML::Stream (was Re: Hang in $r->print w/ POST)
<> "Darren" == darren chamberlain <[EMAIL PROTECTED]> writes: Darren> I recently started looking at the HTML:Stream package, and it looks Darren> pretty interesting. Yes it seems interesting but I'll definitivefy try to switch to templates, BTW the new CGI("") approach Bruce noticed seems to be an interesting one too, maybe by subclassing CGI pkg ? Darren> The only thing(s) I don't like about it are that it calls print on Darren> its own, rather than returning strings, but that is easily fixed. Yes by using: use HTML::Stream qw(:funcs); print html_tag('A', HREF=>$link); print html_escape("<>"); But this is not what I'll call a complete html generator as it do not know html tags by itself. Too many choices with all that wild perl modules ;-) that's good thing! But I really suggest that the pb w/ CGI eating the post data be clearly reported in the mod_perl Guide and FAQ. regards -- / From the last station before the end of the neT \ \ Centre d'Etudes de la Navigation Aerienne, div SSS / / 7, av edouard Belin - 31055 Toulouse CEDEX - France \ \ Tel:(+33|0)5.62.25.95.22 | Fax:(+33|0)5.62.25.95.99 /
HTML::Stream (was Re: Hang in $r->print w/ POST)
heddy Boubaker ([EMAIL PROTECTED]) said something to this effect: > What I meant is a pkg that could generate all known HTML tags, not like > HTML::StickyForms ... > > But all of you guys changed my mind instead of hardcoding the html into my > handler I'll try to investigate the use of templates files (I've too many > choices over there). BTW the handler I'm currently writing could be of > general interest, I'll try to release it to the public community one day so > you'll all critisize it (or legalize it) ;-) I recently started looking at the HTML:Stream package, and it looks pretty interesting. Synopsis: use HTML::Stream; my $r = shift; my $HTML = HTML::Stream($r); # Pass in an object with a print method # or a GLOB ref, e.g., \*STDOUT $HTML->A(HREF=>$r->uri) ->text('I am a link to the current page') ->_A; The only thing(s) I don't like about it are that it calls print on its own, rather than returning strings, but that is easily fixed. I do like the C++-ish method of method chaining. The main problem with it, though, is that it won't plug into existing CGI code, since it calls print on its own. If I decide to use that, I will modify the file, and probably send a patch to the author. (darren) -- When all you have is a hammer, everything looks like a nail. When all you have is inheritance, everything looks like a hierarchy.
Re: Hang in $r->print w/ POST
<> "Patrick" == Patrick <[EMAIL PROTECTED]> writes: Patrick> I'm not sure what you mean by complete, but CGI::FastTemplate always Patrick> suited my needs. Of course there are many other solutions, like Patrick> others have told you : HTML::Mason (seems to be very popular), Patrick> etc... What I meant is a pkg that could generate all known HTML tags, not like HTML::StickyForms ... But all of you guys changed my mind instead of hardcoding the html into my handler I'll try to investigate the use of templates files (I've too many choices over there). BTW the handler I'm currently writing could be of general interest, I'll try to release it to the public community one day so you'll all critisize it (or legalize it) ;-) -- / From the last station before the end of the neT \ \ Centre d'Etudes de la Navigation Aerienne, div SSS / / 7, av edouard Belin - 31055 Toulouse CEDEX - France \ \ Tel:(+33|0)5.62.25.95.22 | Fax:(+33|0)5.62.25.95.99 /
Re: Hang in $r->print w/ POST
Le Fri, Jul 07, 2000 at 02:18:29PM +0200, heddy Boubaker a dit: > to do. I'm just looking for a simple but complete html generator (instead of > hard coding all html tags in my code), does such a beast exists or have I to > write my own? I'm not sure what you mean by complete, but CGI::FastTemplate always suited my needs. Of course there are many other solutions, like others have told you : HTML::Mason (seems to be very popular), etc... HTH -- Patrick. Because if life has a meaning, we should already know it.
Re: Hang in $r->print w/ POST
> "heddy" == heddy Boubaker <[EMAIL PROTECTED]> writes: >> I liked the CGI functions to generate HTML ... it seems there is no >> simple way to tell CGI module not to eat POST data. HTML::StickyForms >> could be an option for forms ... the others (Template, Mason) are not >> for what I'm trying to do. I'm just looking for a simple but complete >> html generator (instead of hard coding all html tags in my code), >> does such a beast exists or have I to write my own? >From the CGI docs: To create an empty query, initialize it from an empty string or hash: $empty_query = new CGI(""); -or- $empty_query = new CGI({}); This gives you a CGI object that you can use to generate your html and leave the query content alone. HTHYO. Peace.
Re: Hang in $r->print w/ POST
<> "Darren" == darren chamberlain <[EMAIL PROTECTED]> writes: Darren> But using CGI's methods invoke CGI's self_or_default meethod, which Darren> will either use the object passed in or create one internally ($Q) Darren> and use that to perform its output. So, even though you are not Darren> explicitly creating a CGI object, you are creating one implicitly, Darren> which is what is grabbing the POSTed data, which is why the script Darren> hangs right where you first try to use a CGI method. Agh! You'r right this is THE reason !! the CGI->init method eat all the POST data !! Is this documented anywhere ? Couldn't this be in the mod_perl Guide or FAQ ? Darren> If you need the HTML generation methods (it looks like this is all Darren> you use CGI for), look into HTML::StickyForm for the forms, and Darren> extend it with your own package for other HTML elements, or use a Darren> templating system like HTML::Template or TemplateToolkit. I prefer to Darren> use HTML::Template, or HTML::Mason when possible, for exactly this Darren> reason. Another option, of course, is to use CGI in an object Darren> oriented fashion, and preload it with -compile to have the entirety Darren> of it reside in the parent process. I liked the CGI functions to generate HTML ... it seems there is no simple way to tell CGI module not to eat POST data. HTML::StickyForms could be an option for forms ... the others (Template, Mason) are not for what I'm trying to do. I'm just looking for a simple but complete html generator (instead of hard coding all html tags in my code), does such a beast exists or have I to write my own? thanks a lot for you answers. -- / From the last station before the end of the neT \ \ Centre d'Etudes de la Navigation Aerienne, div SSS / / 7, av edouard Belin - 31055 Toulouse CEDEX - France \ \ Tel:(+33|0)5.62.25.95.22 | Fax:(+33|0)5.62.25.95.99 /
Re: Hang in $r->print w/ POST
heddy Boubaker ([EMAIL PROTECTED]) said something to this effect: > > <> "Darren" == darren chamberlain <[EMAIL PROTECTED]> writes: > > Darren> Apache::Request retrieves the POSTed content, so if you try to get > Darren> it, the server will hang, waiting for input. With Apache::Request, > Darren> just call the > Darren> $r->param method to fetch the data, and don't try to call it yourself. > > Yes I know that, I didn't try to read something (POST data from stdin) I try > to write (print to stdout). BTW my code act the same if I use Apache::Request > or not... And I forgot to say that I use CGI module in my handler, and that > no other handler eat r->content ... But using CGI's methods invoke CGI's self_or_default meethod, which will either use the object passed in or create one internally ($Q) and use that to perform its output. So, even though you are not explicitly creating a CGI object, you are creating one implicitly, which is what is grabbing the POSTed data, which is why the script hangs right where you first try to use a CGI method. If you need the HTML generation methods (it looks like this is all you use CGI for), look into HTML::StickyForm for the forms, and extend it with your own package for other HTML elements, or use a templating system like HTML::Template or TemplateToolkit. I prefer to use HTML::Template, or HTML::Mason when possible, for exactly this reason. Another option, of course, is to use CGI in an object oriented fashion, and preload it with -compile to have the entirety of it reside in the parent process. Recommendation: Abondon CGI, and go with Apache::Request (or Apache::RequestNote), HTML::StickyForm, and HTML::Template. (darren) -- The goal of technology is to build something that will last at least until we finish building it.
Re: Hang in $r->print w/ POST
<> "Darren" == darren chamberlain <[EMAIL PROTECTED]> writes: Darren> Apache::Request retrieves the POSTed content, so if you try to get Darren> it, the server will hang, waiting for input. With Apache::Request, Darren> just call the Darren> $r->param method to fetch the data, and don't try to call it yourself. Yes I know that, I didn't try to read something (POST data from stdin) I try to write (print to stdout). BTW my code act the same if I use Apache::Request or not... And I forgot to say that I use CGI module in my handler, and that no other handler eat r->content ... Apache v1.3.9 mod_perl v1.21 CGI.pm v2.62 This piece of code illustrate the pb (thanks to give me any hint): #!/usr/local/bin/perl # # Test.pm: Apache::CENA::Test # package Apache::CENA::Test; use diagnostics -verbose; use strict; use Apache::Constants qw(:common); use CGI qw(:html :form :cgi); sub handler { my $r = shift; # Do not bother with HEAD requests return DECLINED if $r->header_only(); # Do not bother with internal sub-requests return DECLINED unless $r->is_main(); # Get POST content & GET args $r->log->info( "Getting args ... " ); my %Args = ($r->args(), $r->content()); my $this = $r->subprocess_env('SCRIPT_URL'); $r->log->info( "Sending headers ... " ); $r->content_type( 'text/html' ); $r->send_http_header(); $r->log->info( "Sending start_html ... " ); # Hangs here in POST methods!!! $r->print( start_html(-title=> $this )); $r->print( h1( $this ), hr()); map{ $r->print( "$_ = ", strong($Args{$_}), br());} keys %Args; $r->print( hr(), a({-href=> "$this?get-arg1=1&get-arg2=2"}, 'GET' ), start_form(-method => 'POST', -action => "$this?get-arg3=3&get-arg4=4"), hidden( -name => 'post-content1', -default => 5 ), hidden( -name => 'post-content2', -default => 5 ), submit( 'POST', 'POST' ), end_form(), end_html() ); $r->log->info( "Done" ); return OK; } 1; # Test.pm ends here -- / From the last station before the end of the neT \ \ Centre d'Etudes de la Navigation Aerienne, div SSS / / 7, av edouard Belin - 31055 Toulouse CEDEX - France \ \ Tel:(+33|0)5.62.25.95.22 | Fax:(+33|0)5.62.25.95.99 /
Re: Hang in $r->print w/ POST
[EMAIL PROTECTED] ([EMAIL PROTECTED]) said something to this effect: > > hi, > > I've a strange pb in a PerlHandler, the subprocess seems to hang in a > $r->print ($r is Apache::Request) after a send_http_header() - wich do not > hang - when called with a POST method (after getting the content). The SAME > code works perfectly if the method is GET! I didn't find any kind of answer > nor in the FAQ, the eagle book, the guide or any other place of my knowledge > ... Help! I really need help please. Apache::Request retrieves the POSTed content, so if you try to get it, the server will hang, waiting for input. With Apache::Request, just call the $r->param method to fetch the data, and don't try to call it yourself. It works with GET's and not POSTS because with GET, Apache::Request doesn't try to read STDIN. (darren) -- Nothing is ever accomplished by a reasonable man.
Re: Hang in $r->print w/ POST
On 6 Jul 2000 [EMAIL PROTECTED] wrote: > > hi, > > I've a strange pb in a PerlHandler, the subprocess seems to hang in a > $r->print ($r is Apache::Request) after a send_http_header() - wich do not > hang - when called with a POST method (after getting the content). The SAME > code works perfectly if the method is GET! I didn't find any kind of answer > nor in the FAQ, the eagle book, the guide or any other place of my knowledge > ... Help! I really need help please. > > thousands thanks in advance are you retrieving form data in another place before this? once you retrieve post data from Apache, it disappears. unless of course you are using Apache::RequestNotes. > > -- > / From the last station before the end of the neT \ > \ Centre d'Etudes de la Navigation Aerienne, div SSS / > / 7, av edouard Belin - 31055 Toulouse CEDEX - France \ > \ Tel:(+33|0)5.62.25.95.22 | Fax:(+33|0)5.62.25.95.99 / > -- Dave Moore Web Application Developer mailto:[EMAIL PROTECTED] ePALS Classroom Exchange http://www.epals.com/ The world's largest online classroom community - Connecting over 27,000 classrooms in 130 countries!
Hang in $r->print w/ POST
hi, I've a strange pb in a PerlHandler, the subprocess seems to hang in a $r->print ($r is Apache::Request) after a send_http_header() - wich do not hang - when called with a POST method (after getting the content). The SAME code works perfectly if the method is GET! I didn't find any kind of answer nor in the FAQ, the eagle book, the guide or any other place of my knowledge ... Help! I really need help please. thousands thanks in advance -- / From the last station before the end of the neT \ \ Centre d'Etudes de la Navigation Aerienne, div SSS / / 7, av edouard Belin - 31055 Toulouse CEDEX - France \ \ Tel:(+33|0)5.62.25.95.22 | Fax:(+33|0)5.62.25.95.99 /