I am happy to announce the the following module for running Mason under Apache 2 / mod_perl 2 with the native Apache 2 request handler (libapreq2).
MasonX::Apache2Handler-0.05 This modules are currently on my site at: <http://beaucox.com/mason> and will be submitted to CPAN shortly. Version 0.05 had been validated against the latest Mason release (1.26). One change - which may affect your installation - has been made: Changed the '$r' passed to Mason pages from type 'Apache::Request' to 'Apache::RequestRec' to conform to the parameter passed to mod_perl 2 handlers. This WILL break your Mason pages that currently use '$r'. Please see the Changes file and the documentation on my site and in the distribution. Partial documentation: NAME MasonX::Apache2Handler - experimental (beta) Mason/mod_perl2 interface SYNOPSIS use MasonX::Apache2Handler; my $ah = MasonX::Apache2Handler->new (..name/value params..); ... sub handler { my $r = shift; $ah->handle_request($r); } DESCRIPTION MasonX::Apache2Handler is experimental ( beta ) and should only be used in a test environment. The MasonX::Apache2Handler module itself is a simple clone of Mason's HTML::Mason::ApacheHandler, and, as such, seems to be solid. However the components used, mod_perl 2 and libapreq2, are currently under development each give a version of the above warning. If you are interested in moving to mod_perl 2 when it reaches production status, I encourage you to try these modules in a test environment; your feedback will help getting mod_perl 2 out the door. I have been using this module on two live sites since mid-January 2004, with no problems. MasonX::Apache2Handler was written to allow Mason to run in a 'pure' mod_perl2/Apache2 environment using the mod_perl2 native request structure as implemented by libapreq2. This is an unofficial release, not supported by the Mason group. If you want to use this module in a testing environment, please address problems, issues, comments, and improvements to me, not Mason. When deciding to port Mason to mod_perl2 I took the approach to add Module(s) rather than patching core Mason modules. Upon investigation I discovered that all the Apache 'glue' code in Mason was contained in HTML::Mason::ApacheHandler. Therefore, I renamed and modified that module to create MasonX::Apache2Handler. The actual changes I made can be found in the distribution in diff/ApacheHandler.diff ( made with 'diff -Naru' ... ). As a result of my approach, you may install the normal Mason ( >= 1.25 ), the modules in "PREREQUISITES" below, and this module. After configuring ( see "CONFIGURATION" below ), you're ready to play. The Apache2Handler object links Mason to mod_perl2, running components in response to HTTP requests. It is controlled primarily through parameters to the new() constructor. handle_request() is not a user method, but rather is called from the HTML::Mason::handler() routine in handler.pl. MasonX::Apache2Handler is a modified copy of the standard HTML::Mason::ApacheHandler. Apache2Handler MUST be used with mod_perl2. You may, however, run Mason with Apache2/mod_perl2 without Apache2Handler (see my rather dated mini-HOWTO at <http://beaucox.com/mason/mason-with-apmp2-mini-HOWTO.htm>), but you then use use 'CGI' requests rather than the native 'mod_perl' requests. The interface is the same as ApacheHandler's, Please refer to HTML::Mason, HTML::Mason::ApacheHandler, and <http://masonhq.com/docs/manual/Admin.html>. NAME CHANGE I have changed module names and released them as of version 0.04 as perl Mason's request: HTML::Mason::ApacheHandler2 => MasonX::Apache2Handler MasonX::Request::WithApacheSession2 => MasonX::Request::WithApache2Session These changes keep my modules out of the 'core' Mason name space. Those of you who have installed my prior modules are encouraged to install the new modules and make the necessary changes to the configuration files and scripts. '$r' IN 0.05 The '$r' passed to Mason pages has been changed from type 'Apache::Request' to 'Apache::RequestRec' to conform to the parameter passed to mod_perl 2 handlers in version 0.05. This WILL break your Mason pages that currently use '$r'. To get the corresponding 'Apache::Request' in your pages under 0.05, do: $rr = Apache::Request->new( $r ); $rr' is now an 'Apache::Request', while '$r' is an 'Apache::RequestRec'. There is a web page in eg/request-examiner.html that displays the type and interface provided by '$r' in your Mason pages. You may want to try this page on your system. Further information may be found on the mod perl site, specifically: <http://perl.apache.org/docs/2.0/user/porting/compat.html#Request_Object _Methods> and <http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html>. PREREQUISITES You must have the following packages installed: perl => 5.8.0 mod_perl => 1.9910 HTML::Mason => 1.25 libapreq2 => 2.02-dev Please refer to the packages' documentation for instructions. WARNING: PERL 5.8.2 ... FLUSH BUFFER AND REDIRECTS I have 'subclassed' HTML::Mason::Request (as MasonX::Request2) and HTML::Mason::Buffer (as MasonX::Buffer2) to change handling of buffer flushing as per Johnathan Kupferer's suggestion (see http://marc.theaimsgroup.com/?l=mason-devel&m=105337019427296&w=2). Basically the buffer is flushed only if there is really anything to flush, which clears the way for $m->redirect( $url );. I have tested this change extensively and found it to be solid. You may wish to uncomment the "print STDERR ..." statements in Burrer2 and Request2 if you wish to see the flushing process at work (or you still have redirect problems). The print STDERR's appear in the Apache log. CONFIGURATION ... Aloha => Beau; -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html