NAME

Maplat::Web - the Maplat WebGUI

SYNOPSIS

The webgui module is the one responsible for loading all actual rendering modules, dispatches calls and handles the browser requests.

my $config = XMLin($configfile,
                  ForceArray => [ 'module', 'redirect', 'menu', 'view', 'userlevel' ],);

$APPNAME = $config->{appname};
print "Changing application name to '$APPNAME'\n\n";

my @modlist = @{$config->{module}};
my $webserver = MaplatWeb->new($config->{server}->{port});
$webserver->startconfig($config->{server});

foreach my $module (@modlist) {
    $webserver->configure($module->{modname}, $module->{pm}, %{$module->{options}});
}


$webserver->endconfig();

# Everything ready to run - notify user
$webserver->run();

DESCRIPTION

This webgui is "the root of all evil". It loads and configures the rendering modules, dispatches browser requests and callbacks/hooks and renders the occasional 404 error messages if no applicable module for the the browsers request is found.

WARNING

Warning! If you are upgrading from 0.91 or lower, beware: There are a few incompatible changes in the server initialization! Please see the Example in the tarball for details.

Configuration and Startup

Configuration is done in stages from the main application, after new(), the first thing to call is startconfig() to prepare the webserver for module configuration. It takes one argument, the maplat specific part of the webserver configuration.

After that, for each module to load, configure() is called, during which the module is loaded and configured.

Next thing is to call endconfig(), which notifies the webserver that all required modules are loaded (the webserver then automatically calls reload() to load all cached data).

After a call to prepare() and an optional call to print_banner() (which the author strongly recommends *grin*) the webserver is ready to handle browser requests.

startconfig

Prepare Maplat::Web for module configuration.

configure

Configure a Maplat::Web module.

endconfig

Finish up module configuration. Also close all open file handles, database and network connections in preparation of forking the webserver if applicable.

handle_request

Handle a web request (internal function).

get_defaultwebdata

Get the %defaultwebdata hash. Internally, this calls all the defaultwebdata callbacks and generates the hash step-by-step.

prerender

Call all registered prerender callbacks. Used by Maplat::Web::TemplateCache.

reload

Call reload() on all configured modules to reload their cached data. This function will not work as expected in a (pre)forking server.

run_task

Run all registered task callbacks. Running tasks in the webgui are deprecated, please use a worker for this functionality. In Maplat::Web, all work should be done on demand, e.g. whenever a page is requested by the client.

sessionrefresh

Run all registered sessionrefresh callbacks.

user_login

Calls all "on login" callbacks when a user is login in.

user_logout

Calls all "on logout" callbacks when a user logs out.

add_defaultwebdata

Add a defaultwebdata callback.

add_loginitem

Add a on login callback.

add_logoutitem

Add a on logout callback.

add_postfilter

Add a postfilter callback.

add_prefilter

Add a prefilter callback.

add_prerender

Add a prerender callback.

add_sessionrefresh

Add a sessionrefresh callback.

add_task

Add a task callback. DEPRECATED, use Maplat::Worker for tasks.

add_webpath

Register a webpath. The registered module/function is called whenever a corresponding path is used in a browser request.

SEE ALSO

Maplat::Worker

Please also take a look in the example provided in the tarball available on CPAN.

AUTHOR

Rene Schickbauer, <rene.schickbauer@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008-2010 by Rene Schickbauer

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