NAME
OpenInteract2::Setup - Setup an OpenInteract2::Context object
SYNOPSIS
# Note: This is normally done ONLY in OpenInteract2::Context
use OpenInteract2::Setup;
# Just used for less typing...
my $setup = OpenInteract2::Setup->new;
# Grab server configuration
my $config = $setup->read_server_config({
website_dir => '/path/to/mysite' });
my $config = $setup->read_server_config({
base_config => $base_config });
# Create a temporary library -- a single directory where we copy all
# Perl modules from the packages used.
my $copied = $setup->create_temp_lib;
print "Files copied to temp library: ", join( ", ", @{ $copied } );
# Same thing, except only copy modules if the temp lib doesn't exist
CTX->global_attribute( temp_lib_create => 'lazy' );
my $copied = $setup->create_temp_lib;
# Build the action table and bring in the necessary classes
my $actions = $setup->read_action_table();
print "Actions in server: ", join( ", ", @{ $actions } );
my $modules = $setup->require_action_classes( $actions );
# Read the SPOPS configuration and build all the SPOPS classes
my $spops_config = $setup->read_spops_config();
print "SPOPS object aliases: ", join( ", ", @{ $aliases } );
my $classes = $setup->activate_spops_classes( $spops_config );
# Build system aliases
my $sys_aliases = $setup->build_aliases;
# Require a bunch of mdules at once
my $required = $setup->require_modules({
class => \@class_list });
my $required = $setup->require_modules({
filename => 'apache_modules.dat' });
DESCRIPTION
METHODS
read_server_config()
The base_config
property of the context must be defined before this is called. Reads in the server configuration, sets information from the base configuration (website name and directory) and calls translate_dirs()
on the server config object.
Throws an exception if it cannot read the server configuration file or on any errors found in creating the OpenInteract2::Config object.
Returns: OpenInteract2::Config-derived object
read_repository()
Opens up a package repository and stores it. Must have the base_config
property defined before calling or an exception is thrown.
Returns: The OpenInteract2::Repository object
read_packages()
Retrieve all packages currently in a website. You must first assign a OpenInteract2::Repository object (run read_repository()
) to the context or this method will throw an exception.
Returns: an arrayref of OpenInteract2::Package objects.
create_temp_dir()
Copies all .pm files from all packages in a website to a temporary library directory. If the 'lazy' global attribute in the context is true and the directory exists, the action will not be performed.
The context must have the packages set before this is run, otherwise an exception is thrown.
Returns: Arrayref of all files copied
read_action_table()
Reads in all available action configurations from all installed packages. While we read in each action configuration we perform a few other tasks, listed below.
Note that when copying default information, we only copy the information if the action key (not just the value) is undefined. This ensures you can define empty action keys and not worry about any default information overwriting it at server startup.
Install the action name in the keys 'key' and 'name' (One of these will probably be chosen before release.)
Copy the package name and version into the action using the keys 'package_name' and 'package_version'.
Copy the filename from which we read the information into the key 'config_file'.
Copy default action information from the global defaults (found in the server configuration key 'action_info.default').
Copy default action information from the local defaults, found in the action 'DEFAULT' in each configuration file. (This is optional.)
Returns: Action table (hashref)
Example:
action.ini
----------------------------------------
[DEFAULT]
author = Chris Winters E<lt>chris@cwinters.comE<gt>
[user]
class = OpenInteract2::Handler::User
security = no
default_task = search_form
[newuser]
class = OpenInteract2::Handler::NewUser
error = OpenInteract2::Error::User
security = no
default_task = show
----------------------------------------
This would result in an action table:
user => {
class => 'OpenInteract2::Handler::User',
security => 'no',
default_task => 'search_form',
key => 'user',
name => 'user',
package_name => 'base_user',
package_version => 1.45,
config_file => '/home/httpd/mysite/pkg/base_user-1.45/conf/action.ini',
author => 'Chris Winters E<lt>chris@cwinters.comE<gt>',
},
newuser => {
class => 'OpenInteract2::Handler::NewUser',
error => 'OpenInteract2::Error::User',
security => 'no',
default_task => 'show'
key => 'newuser',
name => 'newuser',
package_name => 'base_user',
package_version => 1.45,
config_file => '/home/httpd/mysite/pkg/base_user-1.45/conf/action.ini',
author => 'Chris Winters E<lt>chris@cwinters.comE<gt>',
},
require_action_classes()
Scans through all the actions and performs a 'require' on all referenced classes.
Returns: Arrayref of all classes successfully required.
initialize_action_filters()
Reads the conf/filter.ini
file and associates the named actions with the specified filters.
Returns: nothing
read_spops_config()
Reads in all available SPOPS class configurations from all installed packages. When we read in each configuration we perform a few additional tasks (most of them done in OpenInteract2::SPOPS and OpenInteract2::SPOPS::DBI.
Put the name of the SPOPS configuration into the key 'key'
Copy the package name and version into the action using the keys 'package_name' and 'package_version'.
Copy the filename from which we read the information into the key 'config_file'.
Modify the 'isa' field depending on whether the 'use_security' key is set to 'yes'
Modify the 'isa' field based on the datasource used.
Modify the 'creation_security' field to resolve group names into the ID values. (For instance, you can use 'site_admin_group' as an identifier and it will resolve to the ID found in the server configuration key 'default_objects.site_admin_group'.)
Returns: Hashref with SPOPS configuration information in all packages.
activate_spops_process()
Extremely thin wrapper around SPOPS::Initialize which does all the work toward creating and initializing SPOPS classes.
Returns: Arrayref of SPOPS classes properly read and initialized.
read_aliases()
Just read in all the aliases from the server configuration and return them based on type. Currently this just reads in all aliases under 'system_aliases' and returns them under the type 'system'.
Returns: hashref of typed aliases.
Example:
my $aliases = $setup->read_aliases;
foreach my $type ( keys %{ $aliases } ) {
while ( my ( $alias, $alias_to ) = each %{ $aliases->{ $type } } ) {
CTX->alias( $type, $alias, $alias_to );
}
}
initialize_controller()
Reads in all controllers from server configuration and registers them with OpenInteract2::Controller.
initialize_content_generator()
Just call OpenInteract2::ContentGenerator::OpenInteract2::ContentGenerator->initialize().
create_cache()
Create a cache object based on the server configuration. The cache information is held in cache_info.data
, and if the use
property of that is not a true value, we do not do anything. Otherwise we require
the class
property of the cache information and then call new()
on it, returning the cache object.
Returns: OpenInteract2::Cache-derived object.
require_module( \%params )
Does a require
on one or more modules. The modules to be read in can be specified in the parameter 'class' or they can be in a filename named in 'filename', one per line.
BUGS
None known.
TO DO
Nothing known.
SEE ALSO
COPYRIGHT
Copyright (c) 2001-2003 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>