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

NAME

OpenInteract2::Controller - Top-level controller to generate and place content

SYNOPSIS

 # In your adapter:
 
  my $controller = eval {
      OpenInteract2::Controller->new( $request, $response )
  };
  if ( $@ ) {
      $response->content( $@ );
  }
  else {
      $controller->execute;
  }
  $response->send;

DESCRIPTION

The controller determines from the URL or other identifier which action gets executed and what happens the content that action generates. Typically that content gets placed into a larger template (see OpenInteract2::Controller::MainTemplate), but you can perform other tasks as well.

In the big picture, the controller is instantiated and invoked from the adapter (see OpenInteract2::Manual::Architecture) and is really the gateway to the whole content generation process.

METHODS

Class methods

new( $request, $response )

Find the action to create from the data in $request. We do this by passing the request to a series of OpenInteract2::ActionResolver objects, each of which looks at the URL (or other information) from the $request and decides if it should create an OpenInteract2::Action object from it.

Once we get the action object we ask it for its controller class, instantiate an object of that class and assign that controller to the context.

We also notify all the controller observers (classes in OpenInteract2::Observer::Controller) with 'action assigned' and the action created.

Object methods

init()

Called with every request just before a controller is returned. Classes may override.

execute()

Must be implemented by subclass. Should execute the main action and store its content (or its modified content) in the $response.

PROPERTIES

type - Type of controller

generator_type - Type of content generator

initial_action - The initial action used to generate content.

COPYRIGHT

Copyright (c) 2001-2005 Chris Winters. All rights reserved.

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

AUTHORS

Chris Winters <chris@cwinters.com>