META: in the future this functionality may move into a separate class.

Here are the current overridable methods:

META: these are all documented in RegistryCooker.pm, though not using pod. please help to port these to pod and move the descriptions here.

new()

create the class's object, bless it and return it

my $obj = $class->new($r);

$class -- the registry class, usually __PACKAGE__ can be used.

$r -- Apache2::Request object.

default: new()

init()

initializes the data object's fields: REQ, FILENAME, URI. Called from the new().

default: init()

default_handler()

default: default_handler()

run()

default: run()

can_compile()

default: can_compile()

make_namespace()

default: make_namespace()

namespace_root()

default: namespace_root()

namespace_from()

If namespace_from_uri is used and the script is called from the virtual host, by default the virtual host name is prepended to the uri when package name for the compiled script is created. Sometimes this behavior is undesirable, e.g., when the same (physical) script is accessed using the same path_info but different virtual hosts. In that case you can make the script compiled only once for all vhosts, by specifying:

$ModPerl::RegistryCooker::NameWithVirtualHost = 0;

The drawback is that it affects the global environment and all other scripts will be compiled ignoring virtual hosts.

To override the default ModPerl::RegistryCooker methods, first, sub-class ModPerl::RegistryCooker or one of its existing sub-classes, using use base. Second, override the methods.

Those methods that weren't overridden will be resolved at run time when used for the first time and cached for the future requests. One way to to shortcut this first run resolution is to use the symbol aliasing feature. For example to alias ModPerl::MyRegistry::flush_namespace as ModPerl::RegistryCooker::flush_namespace, you can do:

In fact, it's a good idea to explicitly alias all the methods so you know exactly what functions are used, rather then relying on the defaults. For that purpose ModPerl::RegistryCooker class method install_aliases() can be used. Simply prepare a hash with method names in the current package as keys and corresponding fully qualified methods to be aliased for as values and pass it to install_aliases(). Continuing our example we could do: