ClearPress
view release on metacpan or search on metacpan
lib/ClearPress/util.pm view on Meta::CPAN
$Revision: 470 $
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 SUBROUTINES/METHODS
=head2 new - Constructor
my $oUtil = ClearPress::util->new({
'configpath' => '/path/to/config.ini', # Optional
});
=head2 data_path - Accessor to data directory containing config.ini and template subdir
my $sPath = $oUtil->data_path();
=head2 configpath - Get/set accessor for path to config file
$oUtil->configpath('/path/to/configfile/');
my $sConfigPath = $oUtil->configpath();
=head2 config - The Config::IniFiles object for our configpath
my $oConfig = $oUtil->config();
=head2 driver - driver name from config.ini
my $sDriverName = $oUtil->driver();
=head2 dbsection - dev/test/live/application based on $ENV{dev}
my $sSection = $oUtil->dbsection();
=head2 dbh - A database handle for the supported database
my $oDbh = $oUtil->dbh();
=head2 quote - Shortcut for $oDbh->quote('...');
my $sQuoted = $oUtil->quote($sUnquoted);
=head2 transactions - Enable/disable transaction commits
Example: A cascade of object saving
$util->transactions(0); # disable transactions
for my $subthing (@{$thing->subthings()}) { # cascade object saves (without commits)
$subthing->save();
}
$util->transactions(1); # re-enable transactions
$thing->save(); # save parent object (with commit)
=head2 username - Get/set accessor for requestor's username
$oUtil->username((getpwuid $<)[0]);
$oUtil->username($sw->username());
my $sUsername = $oUtil->username();
=head2 cgi - Placeholder for a CGI object (or at least something with the same param() interface)
$oUtil->cgi($oCGI);
my $oCGI = $oUtil->cgi();
=head2 session - Placeholder for a session hashref
$oUtil->session($hrSession);
my $hrSession = $oUtil->session();
=head2 profiler - Placeholder for a Website::Utilities::Profiler object
$oUtil->profiler($oProfiler);
my $oProf = $oUtil->profiler();
=head2 requestor - a ClearPress::model::user who requested this page (constructed by view.pm)
This is usually used for testing group membership for authorisation checks
my $oRequestingUser = $oUtil->requestor();
=head2 log - Formatted debugging output to STDERR
$oUtil->log(@aMessages);
=head2 cleanup - housekeeping stub for subclasses - called when response has completed processing
$oUtil->cleanup();
=head2 db_credentials - hashref of database connection info from the current dbsection
my $hrDBHInfo = $oUtil->db_credentials();
=head2 dbname - database name from db_credentials
my $sDBName = $oUtil->dbname();
=head2 dbuser - database user from db_credentials
my $sDBUser = $oUtil->dbuser();
=head2 dbpass - database pass from db_credentials
my $sDBPass = $oUtil->dbpass();
=head2 dbhost - database host from db_credentials
my $sDBHost = $oUtil->dbhost();
=head2 dbport - database port from db_credentials
my $sDBPort = $oUtil->dbport();
=head2 dsn_opts - database dsn settings from db_credentials
my $sDBDSNOptions = $oUtil->dsn_opts();
( run in 3.038 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )