[Catalyst] Catalyst::View::Mason - updates

Michael Gray mjg17 at eng.cam.ac.uk
Thu May 4 17:37:27 CEST 2006

On Mon, 1 May 2006, Andres Kievsky wrote:

> I'd like to discuss any feature requests/errors/bugs/patches/etc that
> the community/users/etc would like to make to it - I haven't been able
> to follow the Catalyst discussion lists for those few months and I'm
> getting up to date, so if you have anything to say, please say it now
> - or just point me privately to anything relevant.

My MasonSite helper patch has already been mentioned.

Today I found myself reusing some old Mason pages, from Catalyst, which 
made use of attributes of $r (Apache request object).  These are in use 
in a pure Mason app.  In my own Mason view I lashed this up as follows.  
I only needed $r->connection->user, but you get the idea:

  use base 'Catalyst::View::Mason';

  use Apache::FakeRequest;
  use NEXT;

  # This relies on my allow_globals patch to Catalyst::View::Mason
  __PACKAGE__->config->{allow_globals} = [qw($r)];

  our $r;

  sub process {
      my $self = shift;
      my $c    = shift;

      my $connection = bless {}, 'Apache::FakeConnection';
      $r = Apache::FakeRequest->new(connection => $connection);

      $self->template->set_global('$r', $r);

      return $self->NEXT::process($c, @_);

  # Very simple fake of Apache::Connection
  package Apache::FakeConnection;
  use base qw(Class::Accessor::Fast);

This could be rolled into Catalyst::View::Mason, perhaps as an
enabled-by-config option.

I dare say Catalyst gurus could also advise on how to pick up the real
$r as a possibly-dangerous optimisation when the app is running under



More information about the Catalyst mailing list