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::AbstractRequest'];
  }

  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::AbstractRequest object is poured into the top, and when it comes out of the bottom it should be an OpenFrame::AbstractResponse, 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. Futhermore, it is possible to alter the slot pipeline at runtime, by returning a class name (string) from a slot. The class name given will be placed at the end of the slot pipeline, and will inherit the configuration from the slot that created placed it there.

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::AbstractRequest 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::AbstractCookie object, that are later used by other slots. If the action() method returns a string, that string is interpreted as being another slot to go on the end of the slot 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 pipeline in the same order as the action() method returns them.

THE SLOT STORE

The Slot Store is the storage area that the pipeline maintains to provide data to the various slots as needed. It has a couple of methods that are useful to the programmer:

store()

The store() method takes one parameter, any object. This object is stored under its class name and is available for use from any other slot. If an object of a class that is already stored is placed in the slot store the old object is overwritten.

lookup()

The lookup() method takes a class name as a string, and returns an object in the case that the slot store has something belonging to that class inside.

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.

AUTHOR

James A. Duncan <jduncan@fotango.com>

COPYRIGHT

Copyright (C) 2001, Fotango Ltd.

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