Wendy API Reference

This document describes Wendy API. It was last edited on 25 Sep 2007.

Note: not all of listed variables, constants, methods are exported by default. Better specify what symbols you need in use argument. Example:

use Wendy::Util 'meta_get_records';
use Wendy::Config ( 'CONF_NOCACHE', 'CONF_MEMCACHED' );
use Wendy::Hosts qw( get_host_languages all_hosts );

Wendy consists of several modules:

See also:

Wendy.pm

Wendy not exports anything. Only one method is available:

Top

Wendy::Config

Top

Wendy::Db

Wendy provides support for several read-only and write-only DB servers. Write functions named with 'w' prefix. These functions will automatically work with "write"-server -- or with default (CONF_DBHOST) if CONF_WDBHOST not set.

IMPORTANT: use appropriate functions in your module. Call w-functions for modifying queries! For read queries better call meta_get_records.

Top

Wendy::DataCache

Provides methods to store scalar data. Data stored in memory if CONF_MEMCACHED is set, or in the file <host_dir>/cache/dc_<calculated_id> otherwise.

Top

Wendy::Hosts

Top

Wendy::Memcached

For arguments on mc_get, mc_set and mc_delete methods, see set, get, and delete methods in Cache::Memcached documentation.

Top

Wendy::Modules

Wendy::Procs

This module is primarily for handling PROC: procedures in templates.

Top

Wendy::Templates

This is what you will use most. It handles templates, macros contents, etc.

Top

Wendy::Users

Top

Wendy::Util

All stuff goes here.

Top

$WOBJ Object

$WOBJ is object used to get access to Wendy state, initialization information, modules and handlers. Sometimes $WOBJ gets modified, for example template_process puts where a list of processed templates, not to cycle.

How to get $WOBJ

$WOBJ is passed to your wendy_handler as first argument.

Or you can get $WOBJ, by calling Wendy::__get_wobj() method.

What $WOBJ is:

Look ad it's dump:


$VAR1 = { 'HPATH' => 'somepath',
          'LNG' => 'en',
          'HOST' => { 'defaultlng' => '1',
              'id' => '1',
              'host' => 'www.myhost.com' },
          'COOKIES' => {},
          'TPLSTORE' => '/var/www/wendy/var/hosts/www.myhost.com/tpl',
          'RLNGS' => { 'en' => '1' },
          'CGI' => CGI object,
          'DBH' => DBI object, 
          'HANDLERSRC' => '/var/www/wendy/var/hosts/www.myhost.com/lib/somepath.pl',
          'REQREC' => Apache2::RequestRecord object };

It contains information about current host, language and also references to some objects you may need.

CGICGI object. Use to get POST/GET parameters, form headers, etc. see perldoc CGI
DBHDatabase handle. I think you don't need it, look at Wendy::Db, for selecting data with memcached support, use meta_get_records
REQRECmod_perl Apache2::RequestRecord object

Top

Output Object

Output object is a hash reference, in fields of which any output parameter can be customized. The following fields are available now:

dataData to be sent to client. HTML, text, binary, etc
filePath to file, which contents will be sent ( with $r -> sendfile() )
ctypeCustom content-type. Default is text/html.
codeCustom HTTP response code. Default is 200.
ttlSeconds, how long can this page live in cache. Default - forever.
expiresUgly version of ttl, specifies exact expiration timestamp (in seconds).
headersHash-reference to any custom headers header_name => header_value. Cookies are to be set this way currently.
nocache1 or 0 Dont cache my output!
msgStatus message to show after http code.

Full output object can be returned from wendy_handler. But if handler returns scalar (string data) it is assumed to be data part:

return "Hello, world!";
Equals to:
my $output_object = { data => "Hello, world!" };
return $output_object;

Top

That's all, folks!

Top