The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XAO::DO::Web::Config - XAO::Web site configuration object

SYNOPSIS

 sub init {
     my $self=shift;

     my $webconfig=XAO::Objects->new(objname => 'Web::Config');

     $self->embed(web => $webconfig);
 }

DESCRIPTION

This object provides methods specifically for XAO::Web objects. It is supposed to be embedded into XAO::DO::Config object by a web server handler when site is initialized.

METHODS

Adds an HTTP cookie into the internal list. If there is only one parameter we assume it is already encoded cookie, otherwise we assume it is a hash of parameters for CGI->cookie method (see CGI).

If a cookie with that name is already in the list from a previous call to add_cookie() then it gets replaced. This check is only performed if you pass a hash of arguments, not already prepared cookie.

Think of it as if you are adding cookies to you final HTTP response as XAO::Web handler will get all the cookies collected during template processing and send them out for you.

Examples:

 $config->add_cookie($cookie);

 $config->add_cookie(-name => 'sessionID',
                     -value => 'xyzzy',
                     -expires=>'+1h');
cgi (;$)

Returns or sets standard CGI object (see CGI). In future versions this would probably be converted to CGI::Lite or something similar, so do not rely to much on the functionality of CGI.

Obviously you should not call this method to set CGI object unless you are 100% sure you know what you're doing. And even in that case you have to call enable_special_access() in advance.

Example:

 my $cgi=$self->cgi;
 my $name=$cgi->param('name');

Or just:

 my $name=$self->cgi->param('name');
cleanup ()

Removes CGI object, cleans up clipboard. No need to call manually, usually is called as part of XAO::DO::Config cleanup().

clipboard ()

Returns clipboard XAO::SimpleHash object. Useful to keep temporary data between different XAO::Web objects. Cleaned up for every session.

cookies ()

Returns reference to an array of prepared cookies.

disable_special_access ()

Disables use of cgi() method to set a new value.

embeddable_methods ()

Used internally by global Config object, returns an array with all embeddable method names -- add_cookie(), cgi(), clipboard(), cookies(), header(), header_args().

enable_special_access ()

Enables use of cgi() method to set a new value. Normally you do not need this method.

Example:

 $config->enable_special_access();
 $config->cgi(CGI->new());
 $config->disable_special_access();
header (@)

Returns HTTP header. The same as $cgi->header and accepts the same parameters. Cookies added before by add_cookie() method are also included in the header.

Returns header only once, on subsequent calls returns undef.

NOTE: In mod_perl environment CGI will send the header itself and return empty string. Be carefull to check the result for if(defined($header)) instead of just if($header)!

As with the most of Web::Config methods you do not need this method normally. It is called automatically by web server handler at the end of a session before sending out session results.

header_args (%)

Sets some parameters for header generation. You can use it to change page status for example:

 $config->header_args(-Status => '404 File not found');

Accepts the same arguments CGI->header() accepts.

new ($$)

Creates a new empty configuration object.

AUTHOR

Copyright (c) 1999-2001 XAO Inc.

Author is Andrew Maltsev <am@xao.com>.

SEE ALSO

Recommended reading: XAO::Web, XAO::DO::Config.