HTML::Mason::Params - Mason configuration parameters
This document lists all of the Mason configuration parameters that are intended to be used by end users.
Each parameter has two names: a Perl version and an Apache version.
The Perl version uses lowercase_with_underscores
, while the Apache
version uses StudlyCaps
with a Mason
prefix. The conversion from
one version to the other is otherwise very predictable. For example,
autohandler_name
<-->
MasonAutohandlerName
comp_root
<-->
MasonCompRoot
data_cache_defaults
<-->
MasonDataCacheDefaults
The Apache parameter names are used in the Apache configuration file in an httpd-based configuration. They are only effective if you have
PerlHandler HTML::Mason::ApacheHandler
in your httpd.conf
. They cannot be used in conjunction with a
handler.pl-based configuration.
The Perl parameter names are used from Perl code, i.e. anywhere other than the Apache configuration file. For example,
HTML::Mason::Request
parameters to
make_subrequest.
List of variable names, complete with prefix ($@%
), that you intend
to use as globals in components. Normally global variables are
forbidden by strict
, but any variable mentioned in this list is
granted a reprieve via a ``use vars'' statement. For example:
allow_globals => [qw($DBH %session)]
In a mod_perl environment, $r
(the request object) is automatically
added to this list.
Title that you want this ApacheHandler to appear as under Apache::Status. Default is ``HTML::Mason status''. This is useful if you create more than one ApacheHandler object and want them all visible via Apache::Status.
Method to use for unpacking GET and POST arguments. The valid options
are 'CGI' and 'mod_perl'; these indicate that a CGI.pm
or
Apache::Request
object (respectively) will be created for the purposes
of argument handling.
'mod_perl' is the default and requires that you have installed the
Apache::Request
package.
If the args_method is 'CGI', the Mason request object ($m
) will have a
method called cgi_object
available. This method returns the CGI
object used for argument processing.
If args_method is 'mod_perl', the $r
global is upgraded to an
Apache::Request object. This object inherits all Apache methods and
adds a few of its own, dealing with parameters and file uploads. See
Apache::Request
for more information.
While Mason will load Apache::Request
or CGI
as needed at runtime, it
is recommended that you preload the relevant module either in your
httpd.conf or handler.pl file, as this will save some memory.
HTML::Mason::Request::ApacheHandler
True or false, default is true. Indicates whether Mason should
automatically send HTTP headers before sending content back to the
client. If you set to false, you should call $r->send_http_header
manually.
See the sending HTTP headers section of the developer's manual for more details about the automatic header feature.
True or false, default is false. Indicates whether to flush the output buffer after every string is output. Turn on autoflush if you need to send partial output to the client, for example in a progress meter.
File name used for autohandlers. Default is ``autohandler''.
The class to use when creating buffers. Defaults to HTML::Mason::Buffer.
Specifies the maximum size, in bytes, of the in-memory code cache where components are stored. Default is 10 MB. See the code cache section of the administrator's manual for further details.
The class into which component objects are blessed. This defaults to HTML::Mason::Component.
The component root marks the top of your component hierarchy and defines how component paths are translated into real file paths. For example, if your component root is /usr/local/httpd/docs, a component path of /products/index.html translates to the file /usr/local/httpd/docs/products/index.html.
Under Apache and CGI, comp_root defaults to the server's document root. In standalone mode comp_root defaults to the current working directory.
This parameter may be either a scalar or an array reference. If it is a scalar, it should be a filesystem path indicating the component root. If it is an array reference, it should be of the following form:
[ [ key1 => '/path/to/root' ], [ key2 => '/path/to/other/root' ] ]
The ``keys'' for each path must be unique names and their ``values'' must be filesystem paths. These paths will be searched in the provided order whenever a component path must be resolved to a filesystem path.
The class to use when creating a compiler. Defaults to HTML::Mason::Compiler.
Interpreter's notion of the current time (deprecated).
The $m->cache
API to use. '1.1', the default, indicates the newer
API documented in this manual.
'1.0' indicates the old API documented in 1.0x and earlier. This
compatibility layer is provided as a convenience for users upgrading
from older versions of Mason, but will not be supported indefinitely.
A hash reference of default options to use for the $m->cache
command. For example, to use the MemoryCache
implementation
by default,
data_cache_defaults => {cache_class => 'MemoryCache'}
These settings are overriden by options given to particular
$m->cache
calls.
The data directory is a writable directory that Mason uses for various features and optimizations: for example, component object files and data cache files. Mason will create the directory on startup, if necessary, and set its permissions according to the web server User/Group.
Under Apache, data_dir defaults to a directory called ``mason'' under the Apache server root. You will need to change this on certain systems that assign a high-level server root such as /usr!
In non-Apache environments, data_dir has no default. If it is left
unspecified, Mason will not use object files, and the default
data cache class will be
MemoryCache
instead of FileCache
.
True or false, default is true. Indicates whether Mason should decline
directory requests, leaving Apache to serve up a directory index or a
FORBIDDEN
error as appropriate. See the allowing directory requests section of the administrator's manual
for more information about handling directories with Mason.
Escape flags to apply to all <% %> expressions by default. The current valid flags are
h - escape for HTML ('<' => '<', etc.) u - escape for URL (':' => '%3A', etc.)
The developer can override default escape flags on a per-expression basis; see the escaping expressions section of the developer's manual.
If you want to set multiple flags as the default, this should be given as a reference to an array of flags.
File name used for dhandlers. Default is ``dhandler''.
Indicates how errors are formatted. The built-in choices are
The default format under Apache and CGI is either line or html depending on whether the error mode is fatal or output, respectively. The default for standalone mode is text.
The formats correspond to HTML::Mason::Exception
methods named
as_format. You can define your own format by creating an
appropriately named method; for example, to define an ``xml'' format,
create a method HTML::Mason::Exception::as_xml
patterned after one of
the built-in methods.
Indicates how errors are returned to the caller. The choices are fatal, meaning die with the error, and output, meaning output the error just like regular output.
The default under Apache and CGI is output, causing the error to be displayed in the browser. The default for standalone mode is fatal.
A hash reference of escape flags to set for this object. See the section on the set_escape method for more details.
Regular expression indicating which warnings to ignore when loading components. Any warning that is not ignored will prevent the component from being loaded and executed. For example:
ignore_warnings_expr => 'Global symbol.*requires explicit package'
If undef, all warnings are heeded; if '.', all warnings are ignored.
By default, this is set to 'Subroutine .* redefined'. This allows you to declare global subroutines inside <%once> sections and not receive an error when the component is reloaded.
This is the package in which a component's code is executed. For
historical reasons, this defaults to HTML::Mason::Commands
.
The class to use when creating a interpreter. Defaults to HTML::Mason::Interp.
The class to use when creating a lexer. Defaults to HTML::Mason::Lexer.
The maximum recursion depth for the component stack, for the request stack, and for the inheritance stack. An error is signalled if the maximum is exceeded. Default is 32.
Indicates where to send output. If out_method is a reference to a scalar, output is appended to the scalar. If out_method is a reference to a subroutine, the subroutine is called with each output string. For example, to send output to a file called ``mason.out'':
my $fh = new IO::File ">mason.out"; ... out_method => sub { $fh->print($_[0]) }
By default, out_method prints to standard output. Under
Apache, standard output is
redirected to $r->print
.
Text given for this parameter is placed at the end of each component. See also preamble.
Sub reference that is called to postprocess the Perl portion of a compiled component, just before it is assembled into its final subroutine form. The sub is called with a single parameter, a scalar reference to the Perl portion of the component. The sub is expected to process the string in-place. See also preprocess and postprocess_text.
Sub reference that is called to postprocess the text portion of a compiled component, just before it is assembled into its final subroutine form. The sub is called with a single parameter, a scalar reference to the text portion of the component. The sub is expected to process the string in-place. See also preprocess and postprocess_perl.
Text given for this parameter is placed at the beginning of each component. See also postamble.
A list of component paths, optionally with glob wildcards, to load when the interpreter initializes. e.g.
preloads => ['/foo/index.html','/bar/*.pl']
Default is the empty list. For maximum performance, this should only be used for components that are frequently viewed and rarely updated. See the preloading components section of the administrator's manual for further details.
As mentioned in the developer's manual, a component's <%once>
section is executed when it is loaded. For preloaded components, this
means that this section will be executed before a Mason or Apache
request exist, so preloading a component that uses $m
or $r
in a
<%once>
section will fail.
Sub reference that is called to preprocess each component before the compiler does it's magic. The sub is called with a single parameter, a scalar reference to the script. The sub is expected to process the script in-place. This is one way to extend the HTML::Mason syntax with new tags, etc., although a much more flexible way is to subclass the Lexer or Compiler class. See also postprocess_text and postprocess_perl.
The class to use when creating requests. Defaults to HTML::Mason::Request.
The class to use when creating a resolver. Defaults to HTML::Mason::Resolver::File.
True or false, default is false. When false, Mason checks the timestamp of the component source file each time the component is used to see if it has changed. This provides the instant feedback for source changes that is expected for development. However it does entail a file stat for each component executed.
When true, Mason assumes that the component source tree is unchanging: it will not check component source files to determine if the memory cache or object file has expired. This can save many file stats per request. However, in order to get Mason to recognize a component source change, you must remove object files and restart the server (so as to clear the memory cache).
Use this feature for live sites where performance is crucial and where updates are infrequent and well-controlled.
The class into which subcomponent objects are blessed. This defaults to HTML::Mason::Component::Subcomponent.
True or false, default is true. Specifies whether Mason creates object files to save the results of component parsing. You may want to turn off object files for disk space reasons, but otherwise this should be left alone.
True or false, default is true. Indicates whether or not a given
component should use strict
.