Home Wendy
Web engine software

Wendy Home Page / Docs / Module Tutorial
 download   mods   docs   contact 
 

What is Wendy module?

Wendy modules are extension packages, they can contain handlers, Perl modules, resources, templates, etc. Modules can be relatively simple, as Captcha module, which provides only Wendy::Modules::Captcha Perl module, or more complex, like News module, with internal templates, and administration interface.

Wendy module contents

Module package contains:
<module name>.wpm file, with module info, resources description, etc. All additional files go to <module name>.data directory. Example:

 
$ ls /var/www/wendy/var/modules

hello.wpm
hello.data/

$

Where are modules placed

Module files must be placed to <wendy dir>/var/modules. Wendy looks for .wpm files, archives or anything else will not be recognized.

.wpm file contents

.wpm (Wendy Perl Module) file is Perl code file. Lets look at hello.wpm inside:

 
# Generic module installation.

use strict;

# Package name must be eq to module name
package hello;

use File::Spec::Functions;
use File::Path;
use Wendy::Db;

# Module information
our $MODULENAME = 'hello';
our $DESCRIPTION = 'Generic module';
our $AUTHOR = 'Eugene Kuzin, eugenek@45-98.org';

# This proc must be defined
sub module_info
{
        return ( 'Description' => $DESCRIPTION,
                 'Author' => $AUTHOR );
}

# Package contents
our @CONTENTS = (
                 {
                         fname => 'mod_hello.pl',
                         destination => '%HOSTLIBDIR%'
                 },
                 {
                         fname => 'Hello.pm',
                         destination => '%MODULESDIR%',
                         onlyonce => 'true'
                 },
                 {
                        fname => 'teddy.jpg',
                        destination  => '%MODRESDIR%'
                 }
                 );

our @MOREDIRS = ();
our @REQLIST = ();
our $CREATEADDRS = 0;

# Installation handlers must present also
sub install
...
sub uninstall
...

# Return true for perl require
1;


This module carries three files, as listed in @CONTENTS : mod_hello.pl, Hello.pm and teddy.jpg. When module will be installed, install procedure will be called, and copy them according to destination atribute.

Unfinished yet.

eugene kuzin, 2007-2011