Maplat::Web - the Maplat WebGUI
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();
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! 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.
SSL support is currently disabled in the source code due to multiple problems with the implementation.
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.
Prepare Maplat::Web for module configuration.
Configure a Maplat::Web module.
Finish up module configuration. Also close all open file handles, database and network connections in preparation of forking the webserver if applicable.
Handle a web request (internal function).
Get the %defaultwebdata hash. Internally, this calls all the defaultwebdata callbacks and generates the hash step-by-step.
Call all registered prerender callbacks. Used by Maplat::Web::TemplateCache.
Call reload() on all configured modules to reload their cached data. This function will not work as expected in a (pre)forking server.
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.
Run all registered sessionrefresh callbacks.
Calls all "on login" callbacks when a user is login in.
Calls all "on logout" callbacks when a user logs out.
Add a defaultwebdata callback.
Add a on login callback.
Add a on logout callback.
Add a postfilter callback.
Add a prefilter callback.
Add a prerender callback.
Add a sessionrefresh callback.
Add a task callback. DEPRECATED, use Maplat::Worker for tasks.
Register a webpath. The registered module/function is called whenever a corresponding path is used in a browser request.
Add a callback for "cleanup" operations after a page is rendered.
Maplat::Worker
Please also take a look in the example provided in the tarball available on CPAN.
Rene Schickbauer, <rene.schickbauer@gmail.com>
Copyright (C) 2008-2011 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.
To install Maplat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Maplat
CPAN shell
perl -MCPAN -e shell install Maplat
For more information on module installation, please visit the detailed CPAN module installation guide.