NAME

Modwheel - Web framework.

DESCRIPTION

Modwheel is a publishing system for use with web, print, TeX, or whatever medium you have a need to publish in. It is designed to be very extensible and will in the future have drop-in support for several relational databases and templating systems.

Modwheel is currently in a very early alpha development stage.

The current development version of Modwheel should work with MySQL/PostgreSQL and the TemplateToolkit, although porting to other databases or templating systems. shouldn't be much work.

SYNOPSIS

A CGI session of Modwheel can be written like this:

use Modwheel::Session;
use IO::Handle;
use CGI;
*STDOUT->autoflush( );

my $modwheel_config = {
    prefix          => '/opt/modwheel',
    configfile      => 'modwheelcfg.yml',
    site            => 'modwheeltest',
    locale          => 'en_EN',
};

my ($modwheel, $db, $user, $object, $template) =
    modwheel_session($modwheel_config, qw(db user template object));

$db->connect or exit;

# A user-session can also be created, if there is none, the session is anonymous.
#$user->login($username, $password);

# The page is the page to process, it has to be in the templatedir directory.
my $page           = shift @ARGV || 'index.html';
my $directory_id   = $db->path_to_id($directory_path);
$directory_id    ||= Modwheel::Object::MW_TREE_ROOT;

my $cgi = new CGI;

$template->init(input => $page, parent => $directory_id, param => $cgi);
print $template->process();

$db->disconnect;

CONSTRUCTOR

Modwheel->new()

Creates a new Modwheel object.

Arguments:

It requires a hash of configuration options as argument. The configuration keys are:

prefix         - The base Modwheel directory. (i.e /opt/modwheel)
configfile     - Name of the configuration file. (i.e config/modwheelconfig.yml)
logmode        - Where log messages goes. Can be stderr, off or you can
                 install your own loghandler with install_loghandler().
site           - The site to use. Must have a corresponding site directive in the config file.
locale         - The locale to use. (i.e en_EN)
debug          - Turn on debugging features.    
logobject      - A object that can be used in your loghandler for logging.

Returns:

A new Modwheel object if everything was OK. Returns no value if there was an error.

ATTRIBUTES

$modwheel->debug()
$modwheel->set_debug()

If this is on (set to a true value), the modwheel components will print various debugging messages. Turn this off for production environments as it can reveal sensitive information.

$modwheel->logmode()

How to log errors and warnings.

$modwheel->set_logmode($mode)

Sets the current logmode. Default log modes are: stderr and off. Modwheel-Apache installs the log mode: apache2 If logmode is off no logging will happen, but error() will still be set on error.

$modwheel->prefix()
$modwheel->set_prefix($prefix)

The path to search for relative files.

%{$modwheel->config()}

The configuration data structure returned by YAML. Returns hash reference.

$modwheel->set_config($href)

Save the configuration data structure. You rarely want to use this.

$modwheel->configfile()
$modwheel->set_configfile($filename)

The YAML configuration file to use. For more information about YAML please see: http://www.yaml.org.

$modwheel->site()
$modwheel->set_site($site)

The name of the current site to use. This is the name used when getting site configuration with siteconfig(). If no site is specified, it uses the defaultsite specified in the global section of the configuration.

$modwheel->logobject() =item $modwheel->set_logobject($your_object)

If you install a log handler with $modwheel->install_loghandler() you save a object here for use within your log handler.

$modwheel->error()

Holds the last error string passed to log().

$modwheel->locale()

Current locale in use.

INSTANCE METHODS

$modwheel->set_locale($locale)

Sets the current locale using POSIX::setlocale.

$modwheel->setup_locale_globally()

If no custom locale is passed when creating a Modwheel object, it sets up the locale using either the locale specified in the current siteconfig or the locale specified in the global section of the configuration file.

$modwheel->siteconfig()

Returns the current siteconfig using the site name in $self-site>.

$modwheel->install_loghandler($name, $code_ref)

Installs new log handler, $code_ref must be an anonymous subroutine.

This is and example how Apache2-Modwheel can make an handler to log messages with the apache2 request object's Apache2::Log::log_error();

my $log_handler_ref = sub {
    my ($modwheel, $log_string) = @_;
    my $apache2_request = $modwheel->logobject;
    $apache2_request->log_error( $log_string );
    return;
}
$modwheel->set_logobject($r);
$modwheel->install_handler('apache2', $log_handler_ref);
$modwheel->logmode('apache2');

Or to install the handlers when calling Modwheel->new

my $modwheel = Modwheel->new(
    # [....]
    logobject       => $r,
    add_loghandlers => {
        apache2         => $log_handler_ref;
    },
    logmode         => 'apache2',
    # [....]
$modwheel->parseconfig()

Example:

$modwheel->set_config("/opt/modwheel/testconfig.yml");
my $config = $modwheel->parseconfig();
$modwheel->set_config($config);

We use YAML for parsing our configuration file specified in configfile(). Exits if the configuration file does not exist. Returns: Hashref to the data structure returned by YAML::LoadFile.

$modwheel->dumpconfig()

Dumps a scalar string representation of the configurations YAML data structure.

$modwheel->logerror(@strings)

Log an error.

$modwheel->logwarn(@strings)

Log a warning.

$modwheel->loginform(@strings)

Log some informative text.

$modwheel->log(string facility, string logstr)

The private logging function, shouldnÕt be used directly. Use the logerror/logwarn/loginform functions instead.

$modwheel->throw($exception)

Throw an exception. Adds the exception to the exceptions array.

$modwheel->exception()

Pop a exception off the exceptions array.

$modwheel->catch($exception)

Search the exceptions array for an exception. Returns 1 if found and 0 if not found.

$modwheel->catch_like($regex)

Like catch() but searches the exceptions array by using regular expression.

PRIVATE ATTRIBUTES AND METHODS

$modwheel->set_error()

Set the error message. This is a private function, use the log* methods instead.

@{ $modwheel->exceptions() }

This is the internal array used by the exceptions system. Use $modwheel->throw(), $modwheel->catch(), $modwheel->catch_like() and $modwheel->exception() instead.

EXPORT

None.

HISTORY

v0.3.1

Now it's possible to create your own object types.

0.01

Initial version.

SEE ALSO

The README included in the Modwheel distribution.

The Modwheel website: http://www.0x61736b.net/Modwheel/

AUTHORS

Ask Solem, ask@0x61736b.net.

COPYRIGHT, LICENSE

Copyright (C) 2007 by Ask Solem ask@0x61736b.net.

All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 526:

Non-ASCII character seen before =encoding in 'shouldnÕt'. Assuming CP1252