=head1 Maypole Request Hacking Cookbook Hacks; design patterns; recipes: call it what you like, this chapter is a developing collection of techniques which can be slotted in to Maypole applications to solve common problems or make the development process easier. As Maypole developers, we don't necessarily know the "best practice" for developing Maypole applications ourselves, in the same way that Larry Wall didn't know all about the best Perl programming style as soon as he wrote Perl. These techniques are what we're using at the moment, but they may be refined, modularized, or rendered irrelevant over time. But they've certainly saved us a bunch of hours work. =head2 Frontend hacks These hacks deal with changing the way Maypole relates to the outside world; alternate front-ends to the Apache and CGI interfaces, or subclassing chunks of the front-end modules to alter Maypole's behaviour in particular ways. =head3 Debugging with the command line You're seeing bizarre problems with Maypole output, and you want to test it in some place outside of the whole Apache/mod_perl/HTTP/Internet/browser circus. B: Use the C module to go directly from a URL to standard output, bypassing Apache and the network altogether. C is not a standalone front-end, but to allow you to debug your applications without having to change the front-end they use, it temporarily "borgs" an application. If you run it from the command line, you're expected to use it like so: perl -MMaypole::CLI=Application -e1 'http://your.server/path/table/action' For example: perl -MMaypole::CLI=BeerDB -e1 'http://localhost/beerdb/beer/view/1?o2=desc' You can also use the C module programatically to create test suites for your application. See the Maypole tests themselves or the documentation to C for examples of this. =head3 Changing how params are parsed =head3 REST =head2 Content display hacks These hacks deal primarily with the presentation of data to the user, modifying the C template or changing the way that the results of particular actions are displayed. =head3 Template Switcheroo An action doesn't have any data of its own to display, but needs to display B. B: This is an B common hack. You've just issued an action like C, which updates the database. You don't want to display a page that says "Record updated" or similar. Lesser application servers would issue a redirect to have the browser request C> instead, but we can actually modify the Maypole request on the fly and, after doing the update, pretend that we were going to C> all along. We do this by setting the objects in the C slot and changing the C