Discussion:
[Mason-devel] $r->header_out / $r->header_in / $m->log - all not defined!
Jason Vas Dias
2010-05-26 15:05:14 UTC
Permalink
Hi -
Being very pleased to find HTML::Mason purporting to provide everything I'd
expect from a Web-Programing framework (and alot more!) I was disappointed
to find that many of the "$src/samples/*" or documentation code example
snippets can be made to work only with major modication - for example
the "samples/dump-request" sample code produces the error:

System error
error: Can't locate object method "header_in" via package
"Apache2::RequestRec" at /home/jason/public_html/cgi-bin/dump-request.mcgi
line 18.
context:
...
14: $r-><a href="#uri">uri</a>(&nbsp;[$uri]&nbsp;)&nbsp;=&nbsp;<% $r->uri()
%><BR>
15: $r-><a href="#filename">filename</a>(&nbsp;
[$filename]&nbsp;)&nbsp;=&nbsp;<% $r->filename() %><BR>
16: $r-><a href="#path_info">path_info</a>(&nbsp;
[$path_info]&nbsp;)&nbsp;=&nbsp;<% $r->path_info() %><BR>
17: $r-><a href="#args">args</a>&nbsp;=&nbsp;<% $r->args %><BR>
18: $r-><a href="#header_in">header_in</a>(&nbsp;$header_name,&nbsp;
[$value]&nbsp;)&nbsp;=&nbsp;<% $r->header_in("Content-type") %><BR>
19: $r-><a href="#get_remote_host">get_remote_host</a>&nbsp;=&nbsp;<% $r-
get_remote_host %><BR>
20: $r-><a href="#requires">requires</a>&nbsp;=&nbsp;<% $r->requires %><BR>
21: $r-><a href="#auth_type">auth_type</a>&nbsp;=&nbsp;<% $r->auth_type
%><BR>
22: $r-><a href="#auth_name">auth_name</a>&nbsp;=&nbsp;<% $r->auth_name
%><BR>
...
code stack: /home/jason/public_html/cgi-bin/dump-request.mcgi:18
raw error

This happens under both Fedora Core 12:
httpd-2.2.14-1.fc12.x86_64
apr-devel-1.3.9-3.fc12.x86_64
and RHEL-5:
httpd-2.2.3-43.el5
apr-devel-1.2.7-11.el5_3.1
.

I'm trying to set a cookie value in a cgi script :

my $Cookie = CGI::Cookie->new(-name=>'text2car_client', value=>$cookie);
$r->header_out('Set-Cookie' => $Cookie );

How is one meant to do this in Mason without use of the header_out() routine -
attempts to print a header even with '(CGI->new())->header(...)' end up
including the header in the document data.

Also, there is no $m->log object, as documented at
http://www.masonhq.com/docs/manual/Devel.html#logging

Is HTML::Mason being maintained ?

Is there any up-to-date documentation for it that contains working examples ?

I'm beginning to conclude that the answer to both questions is "NO" and that I
should use the raw mod_perl / CGI.pm interfaces instead.

I hope someone can disabuse me of this conclusion - as documented, Mason looks
great, but it is currently not behaving as documented .

Thanks in advance,
Jason.
Jonathan Swartz
2010-05-26 16:33:05 UTC
Permalink
Hi Jason,

First, to your specific questions:
* The src/samples are mod_perl 1 specific, which is why they aren't
working in your Apache/mod_perl 2 environment. It's hard to provide
samples that work in both, we should probably just delete those.
* $m->log should certainly work, what happens when you use it? Are you
using the latest version of Mason?

More generally:
* Mason is very stable so doesn't change much these days.
* Mason 2 is in progress - see http://www.openswartz.com/2009/09/01/what-mason-2-0-would-look-like/
* In terms of providing web framework capabilities, Mason has been
superseded by frameworks such as CGI::Application, Catalyst and Jifty.
See

http://www.perlfoundation.org/perl5/index.cgi?web_frameworks

Once you choose a framework, you can choose to use Mason as a
templating language, or something else such as Template::Toolkit or
HTML::Template.

Hope that helps,
Jon
Post by Jason Vas Dias
Hi -
Being very pleased to find HTML::Mason purporting to provide
everything I'd
expect from a Web-Programing framework (and alot more!) I was
disappointed
to find that many of the "$src/samples/*" or documentation code example
snippets can be made to work only with major modication - for example
System error
error: Can't locate object method "header_in" via package
"Apache2::RequestRec" at /home/jason/public_html/cgi-bin/dump-
request.mcgi
line 18.
...
14: $r-><a href="#uri">uri</a>(&nbsp;[$uri]&nbsp;)&nbsp;=&nbsp;<% $r->uri()
%><BR>
15: $r-><a href="#filename">filename</a>(&nbsp;
[$filename]&nbsp;)&nbsp;=&nbsp;<% $r->filename() %><BR>
16: $r-><a href="#path_info">path_info</a>(&nbsp;
[$path_info]&nbsp;)&nbsp;=&nbsp;<% $r->path_info() %><BR>
17: $r-><a href="#args">args</a>&nbsp;=&nbsp;<% $r->args %><BR>
18: $r-><a href="#header_in">header_in</a>(&nbsp;$header_name,&nbsp;
[$value]&nbsp;)&nbsp;=&nbsp;<% $r->header_in("Content-type") %><BR>
19: $r-><a href="#get_remote_host">get_remote_host</
a>&nbsp;=&nbsp;<% $r-
get_remote_host %><BR>
20: $r-><a href="#requires">requires</a>&nbsp;=&nbsp;<% $r-
requires %><BR>
21: $r-><a href="#auth_type">auth_type</a>&nbsp;=&nbsp;<% $r-
auth_type
%><BR>
22: $r-><a href="#auth_name">auth_name</a>&nbsp;=&nbsp;<% $r-
auth_name
%><BR>
...
code stack: /home/jason/public_html/cgi-bin/dump-request.mcgi:18
raw error
httpd-2.2.14-1.fc12.x86_64
apr-devel-1.3.9-3.fc12.x86_64
httpd-2.2.3-43.el5
apr-devel-1.2.7-11.el5_3.1
.
my $Cookie = CGI::Cookie->new(-name=>'text2car_client', value=>
$cookie);
$r->header_out('Set-Cookie' => $Cookie );
How is one meant to do this in Mason without use of the header_out() routine -
attempts to print a header even with '(CGI->new())->header(...)' end up
including the header in the document data.
Also, there is no $m->log object, as documented at
http://www.masonhq.com/docs/manual/Devel.html#logging
Is HTML::Mason being maintained ?
Is there any up-to-date documentation for it that contains working examples ?
I'm beginning to conclude that the answer to both questions is "NO" and that I
should use the raw mod_perl / CGI.pm interfaces instead.
I hope someone can disabuse me of this conclusion - as documented, Mason looks
great, but it is currently not behaving as documented .
Thanks in advance,
Jason.
------------------------------------------------------------------------------
_______________________________________________
Mason-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mason-devel
David E. Wheeler
2010-05-26 16:35:25 UTC
Permalink
Post by Jonathan Swartz
* Mason is very stable so doesn't change much these days.
* Mason 2 is in progress - see http://www.openswartz.com/2009/09/01/what-mason-2-0-would-look-like/
Oh, has there been work since then? Care to post a status report?

Best,

David
Jonathan Swartz
2010-05-26 16:44:47 UTC
Permalink
Post by David E. Wheeler
Post by Jonathan Swartz
* Mason is very stable so doesn't change much these days.
* Mason 2 is in progress - see http://www.openswartz.com/2009/09/01/what-mason-2-0-would-look-like/
Oh, has there been work since then? Care to post a status report?
I've been working on it when I have time, usually on airplanes/
trains. :) There's nothing to report yet, but hopefully soon - I'd
like to have something to show at yapc.

Jon
David E. Wheeler
2010-05-26 17:04:44 UTC
Permalink
Post by Jonathan Swartz
Post by David E. Wheeler
Oh, has there been work since then? Care to post a status report?
I've been working on it when I have time, usually on airplanes/
trains. :) There's nothing to report yet, but hopefully soon - I'd
like to have something to show at yapc.
Awesome, I look forward to hearing more.

Best,

David

Loading...