The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

OpenFrame::Slot - Information about OpenFrame Slots

SYNOPSIS

  package OpenFrame::Slot::MyRequestNoter;

  use strict;

  use OpenFrame::Slot;
  use base qw ( OpenFrame::Slot );

  sub what {
    return ['OpenFrame::Request'];
  }

  sub action {
    my $self = shift;
    my $conf = shift;
    my $req  = shift;

    &warn("URL Requested is: " . $req->uri()->as_string());
  }

  1;

DESCRIPTION

OpenFrame Slot functionality is designed as a pipe where transmogrification takes place. An OpenFrame::Request object is poured into the top, and when it comes out of the bottom it should be an OpenFrame::Response, that contains all the information that is needed by any server to deliver content to a browser. In between the top and the bottom of the pipe functionality is executed in a serial fashion.

A second pipeline known as the "cleanup pipeline" is used to schedule slots that should be run after the main slot pipeline has completed (e.g. to perform post-processing cleanup operations). This is initially empty and may be filled by slots in the regular pipeline as they are run.

WHAT'S IN A SLOT

Any slot should inherit from the OpenFrame::Slot class. This provides the basic functionality that a slot needs to get going. However, from any given slot there should be two methods that programmers need to concern themselves with, what() and action().

what()

The what() method returns an array reference containing the classes that any given slot needs to function. For instance, the packaged class OpenFrame::Slot::Session requires an OpenFrame::Request object in order to perform its action, and therefore returns it inside an array when its what() method is called. A slot can also place OpenFrame::SlotStore in its required parameters list and then receive the entire slot store.

action()

The action() method takes the parameters that you specify in the what() method as well as a the config that the slot is installed with and does something with them. If it returns an object then that object gets kept for future use by other slots. For example, the OpenFrame::Slot::Session class returns both an OpenFrame::Session object and a OpenFrame::Cookietin object, that are later used by other slots. If the action() method returns a string, that string is interpreted as the name of another slot which should be added to the end of the cleanup pipeline.

The action method can return values as a single scalar, or as a list. In the case of a list of Slots to be executed they go onto the cleanup pipeline in the same order as the action() method returns them.

If a slot returns an OpenFrame::Response object then the request is deemed complete and the remaining slots in the main pipeline are bypassed. At this point, any slots in the cleanup pipeline are then run.

THE SLOT STORE

The Slot Store is the storage area that the pipeline maintains to provide data to the various slots as needed. This is implemented by the OpenFrame::SlotStore module.

NOTES

The slot store also keeps a copy of itself, so if you make a request for OpenFrame::SlotStore in your paramter list returned from what() then you can get access to everything in the store.

AUTHORS

James A. Duncan <jduncan@fotango.com> and Andy Wardley <abw@kfs.org>.

COPYRIGHT

Copyright (C) 2001-2, Fotango Ltd.

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.