I'm trying to wrap a legacy mod_perl mason app in Plack. I started off easily enough, using Plack::App::FakeApache::Request and looking at request methods not in that module that needed adding, but now I'm hitting a slight roadbloak.

I don't want to have to edit any standard modules if I can avoid it, but the change I would need to make isn't easily overloaded.

The BEGIN block of HTML::Mason::ApacheHandler checks whether the request object ISA Apache2::RequestRec object or not. It's actually a Plack::App::FakeApache::Request so the Mason handler dies with the message:

The 'apache_req' parameter ("Plack::App::FakeApache::Request=HASH(0xa2ffd60)") to HTML::Mason::Request::ApacheHandler->new() was not a 'Apache2::RequestRec' (it is a Plack::App::FakeApache::Request=HASH(0xa2ffd60))

I was thinking of reblessing it before it hits Mason, but I can see that coming back to bite me.

Is there a better way to approach this? Should I give up on the Fake Request and just re-implement the Mason direct through Plack, using HTML::Mason::PlackHandler (say), and that the app rewrite will be less work than trying to get the existing app wrapped in the fake Apache handler?

Edit: After a bit more digging, I think I found a solution. Looks like the module I needed to look at was Plack::Request and to then tweak the Mason code, rather than trying to fake everything through the Apache handler.


In reply to Plack::App::FakeApache::Request & Mason by cLive ;-)

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.