Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TeeJay (2309)

TeeJay
  (email not shown publicly)
http://www.aarontrevena.co.uk/

Working in Truro
Graduate with BSc (Hons) in Computer Systems and Networks
pm : london.pm, bath.pm, devoncornwall.pm
lug : Devon & Cornwall LUG
CPAN : TEEJAY [cpan.org]
irc : TeeJay
skype : hashbangperl
livejournal : hashbangperl [livejournal.com]
flickr :hashbangperl [flickr.com]

Journal of TeeJay (2309)

Tuesday June 05, 2007
03:18 PM

Funky new feature in Maypole 2.12 / SVN

[ #33435 ]
I've added a new hook into the Maypole request process - preprocess_location - allows you to do what it says on the tin - you can rewrite urls, or as I've done today - you can set configuration per request based on hostname and path..

sub preprocess_location {
  my $self = shift;

  # get uri base, template_paths, client, etc from url
  my $site_config = My::Config->get_site(scheme=>'http', host=>$self->headers_in->get('host'), path => $self->ar->uri);

  $self->config->additional->{site_config} = $site_config;
  $self->config->additional->{client_id} = $site_config->client_id;
  $self->config->uri_base($site_config->base_uri);

  my $custom_path = $site_config->custom_path;
  if ($custom_path) {
    my $default_path = $ENV{TEMPLATE_ROOT};
    my $template_paths = [ $custom_path, $default_path ];
    $self->config->template_root($template_paths);
  }
  return;
}

The Config package in turn uses Config::Context to load per host/path configuration from an apache style config file.

sweeeeet
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.