Embedding Perl in HTML with Mason: Appendix B

# Appendix B: Object Constructor Parameters

This appendix provides a quick reference to all the constructor parameters of the major pieces of the Mason framework. See Chapter 6 or the official Mason documentation for more detail, including information on how and where to specify them.

It's important to understand the relationships among the various pieces of Mason's framework; Figure B-1 shows how they relate to one another. Keep in mind that you can pass any class's parameters to a class that contains it. For example, you can pass any Compiler parameters to the `new()` method of the Interpreter, ApacheHandler, or CGIHandler. In the figure, the solid arrows indicate a "contains one" relationship, and the dashed arrows indicate a "contains many" relationship.

Figure B-1. An outline for the Mason framework

## HTML::Mason::Interp

Name | Type | Default | Description
autohandler_name (MasonAutohandlerName) | string | autohandler | The filename to use for Mason's 'autohandler' capability
code_cache_max_size (MasonCodeCacheMaxSize) | string | 10485760 | The maximum size of the component code cache
compiler (MasonCompiler) | object | HTML::Mason::Compiler::ToObject->new | A Compiler object for compiling components
data_dir (MasonDataDir) | string |  | A directory for storing cache files and other state information
ignore_warnings_expr (MasonIgnoreWarningsExpr) | regex | qr/Subroutine .* redefined/i | A regular expression describing Perl warning messages to ignore
preloads (MasonPreloads) | list |  | A list of components to load immediately when creating the Interpreter
resolver (MasonResolverClass) | object | HTML::Mason::Resolver::File->new | A Resolver object (or class) for fetching components from storage
static_source (MasonStaticSource) | boolean | 0 | When true, we only compile source files once
use_object_files (MasonUseObjectFiles) | boolean | 1 | Whether to cache component objects on disk

Table B-1.

## HTML::Mason::Request

Name | Type | Default | Description
autoflush (MasonAutoflush) | boolean | 0 | Whether output should be buffered or sent immediately
data_cache_defaults (MasonDataCacheDefaults) | hash |  | A hash of default parameters for Cache::Cache
dhandler_name (MasonDhandlerName) | string | dhandler | The filename to use for Mason's 'dhandler' capability
error_format (MasonErrorFormat) | string | text | How error conditions are returned to the caller (brief, text, line or html)
error_mode(MasonErrorMode) | string | fatal | How error conditions are manifest (output or fatal)
max_recurse (MasonMaxRecurse) | string | 32 | The maximum recursion depth for component, inheritance, and request stack
out_method (MasonOutMethod) | code | sub { package HTML:: Mason::Request; print STDOUT grep({defined $_;}@_); } | A subroutine or scalar reference through which all output will pass

Table B-2.

## HTML::Mason::Resolver::File

Name | Type | Default | Description
comp_root (MasonCompRoot) | list | DocumentRoot in a web setting, current directory in a standalone setting | A string or array of arrays indicating the search path for component calls

Table B-3.

## HTML::Mason::ApacheHandler

Name | Type | Default | Description
apache_status_title (MasonApacheStatusTitle) | string | HTML::Mason status | The title of the Apache::Status page
args_method(MasonArgsMethod) | string | mod_perl | Whether to use CGI.pm or Apache::Request for parsing the incoming HTTP request
decline_dirs (MasonDeclineDirs) | boolean | 1 | Whether Mason should decline to handle requests for directories
interp (MasonInterpClass) | object | HTML::Mason::Interp->new | A Mason interpreter object (or class) for processing components

Table B-4.

## HTML::Mason::Compiler

Name | Type | Default | Description
allow_globals (MasonAllowGlobals) | list | [ ] | An array of names of Perl variables that are allowed globally within components
default_escape_flags (MasonDefaultEscapeFlags) | string |  | Escape flags that will apply by default to all Mason tag output
lexer (MasonLexerClass) | object | HTML::Mason::Lexer->new | A Lexer object (or class) that will scan component text during compilation
postprocess_perl (MasonPostprocessPerl) | code |  | A subroutine through which all Perl code will be sent during compilation
postprocess_text (MasonPostprocessText) | code |  | A subroutine through which all plain text will be sent during compilation
preprocess (MasonPreprocess) | code |  | A subroutine through which all component text will be sent during compilation

Table B-5.

## HTML::Mason::Component

None.

## HTML::Mason::Buffer

None.

## HTML::Mason::CGIHandler

None.

## HTML::Mason::Lexer

None.