Apache2-Controller
view release on metacpan or search on metacpan
lib/Apache2/Controller.pm view on Meta::CPAN
rolled back automatically in the C<< PerlLogHandler >>
phase if you don't commit the transaction.
=head1 CONTROLLER CLOSURES
Apache2::Controller's package space structure lets you take advantage
of closures that access variables in your controller subclass
package space, which are cached by modperl in child processes
across independent web requests. Be careful with that and use
Devel::Size to keep memory usage down. I have no idea how this
would work under threaded mpm.
=head1 CONTENT TYPE
Your controller should set content type with C<< $self->content_type() >>
to something specific if you need that. Otherwise it will let
mod_perl set it to whatever it chooses when you start to print.
This is usually text/html.
=head1 LOGGING
lib/Apache2/Controller/DBI/Connector.pm view on Meta::CPAN
your database handles on an ad-hoc basis from your controllers.
If directive C<< A2C_DBI_Cleanup >> is set, a C<< PerlLogHandler >>
gets pushed which will roll back any open transactions. So if your
controller does some inserts and then screws up, you don't have to
worry about trapping these in eval if you want the DBI errors to
bubble up. They will be automatically rolled back since C<< commit() >>
was never called.
(This used to be a PerlCleanupHandler, but it appears that Apache
hands this off to a thread even if running under prefork, and
cleanup doesn't always get processed before the child handles
the next request. At least, this is true under L<Apache::Test>.
Wacky. So, it's a PerlLogHandler to make sure the commit or
rollback gets done before the connection dies.)
If you subclass, you can set up multiple dbh handles with different params:
<Location '/busy/database/page'>
SetHandler modperl
lib/Apache2/Controller/Session.pm view on Meta::CPAN
(If this is not useful and correct behavior contact me and I
will add another switch, but it seems right to me.)
It actually re-orders the C<PerlLogHandler> stack so that
its handlers run first, before the handler pushed by
L<Apache2::Controller::DBI::Connector> commits the database
transaction, for example.
This used to push a C<PerlCleanupHandler> to save the session,
which made sense at the time, but the OpenID auth tests revealed
that the Cleanup handler is apparently assigned a thread to
process it independently, even under prefork with C<Apache::Test>.
So, the test script was firing off a new request
before the old request Cleanup handler ran to save the session,
which resulted in sporadic and inconsistent failures...
yeah, THOSE kind, you know the type, the most maddening ones.
Apache::Session does not always save automatically, for
example if you change something in the bottom tier of
a multi-level hash. If you want to, set the directive flag
C<A2C_Session_Always_Save> and this will set a top-level
t/dbi_connector.t view on Meta::CPAN
plan tests => scalar(@tests / 2), need_module qw( LWP DBD::SQLite );
my $i = -2;
my $j = -1;
while (exists $tests[$i += 2] && exists $tests[$j += 2]) {
( my $content = GET_BODY("/dbi_connector/$tests[$i]") ) =~ s{ \s+ \z }{}mxs;
# od($content);
ok t_cmp($content => $tests[$j], $tests[$j]);
} # how do you like them apples, oh evil thread-unsafe natatime() ?
( run in 0.615 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )