| Handel documentation | view source | Contained in the Handel distribution. |
Handel::ConfigReader - Read in Handel configuration settings from ENV/ModPerl
use Handel::ConfigReader;
my $cfg = Handel::ConfigReader->instance();
my $setting = $cfg->get('HandelMaxQuantity');
my $other = $cfg->{'OtherSetting'};
Handel::ConfigReader is a generic wrapper to get various configuration values. As some point this will probably get worked into XS/custom httpd.conf directives.
Each configuration object is also a tied hash. The two usages are the same:
my $cfg = Handel::ConfigReader->instance();
my $setting = $cfg->get('Setting');
my $setting = $cfg->{'Setting'};
The latter is the preferred usage in anticipation of also integrating Apache::ModuleConfig and custom directives which use the same hash syntax.
Returns a new Handel::ConfigReader instance.
my $cfg = Handel::ConfigReader->new();
Returns the same Handel::ConfigReader instance for each call.
my $cfg = Handel::ConfigReader->instance();
Returns the configured value for the key specified. You can use this as an instance method or as a simpleton:
my $cfg = Handel::ConfigReader->instance();
my $setting = $cfg->get('HandelMaxQuantity');
my $cfg = Handel::ConfigReader->instance();
my $setting = $cfg->get('HandelMaxQuantity');
You can also pass a default value as the second parameter. If no value is loaded for the key specified, the default value will be returned instead.
my $cfg = Handel::ConfigReader->instance();
my $setting = $cfg->get('DoesNotExist', 'foo');
print $setting; # foo
Returns an item form the configuration via tied hash.
my $cfg = Handel::ConfigReader->new;
my $setting = $cfg->{'MySetting'};
Returns true if the specified setting returns a defined value.
my $cfg = Handel::ConfigReader->new;
if (exists $cfg->{'MySetting'}) {
...
};
Does nothing.
Does nothing.
Does nothing.
Various Handel runtime options can be set via %ENV variables, or using
PerlSetVar when running under mod_perl.
PerlSetVar HandelMaxQuantity 32
...
$ENV{HandelMaxQuantity} = 32;
If defined, this sets the maximum quantity allowed for each
Handel::Cart::Item in the shopping cart. By default, when the user request
more than HandelMaxQuantity, quantity is reset to HandelMaxQuantity.
If you would rather raise an Handel::Exception::Constraint instead, see
HandelMaxQuantityAction below.
This option defines what action should be taken when a cart items quantity is
being set to something above HandelMaxQuantity. When set to Adjust the
quantity will simply be reset to HandelMaxQuantity and no exception will be
raised. This is the default action.
When set to <Exception> and the quantity requested is greater than
HandelMaxQuantity, a Handel::Exception::Constraint exception is thrown.
This sets the default currency code used when no code is passed into format.
See Locale::Currency::Format for all available currency codes. The default
code is USD.
This sets the default options used to format the price. See
Locale::Currency::Format for all available currency codes. The default format
used is FMT_STANDARD. Just like in Locale::Currency::Format, you can
combine options using |.
The name of the DBD driver. Defaults to mysql.
The name of the database server. Defaults to localhost.
The port of the database server. Defaults to 3306.
The name of the database. Defaults to commerce.
The user name used to connect to the server. Defaults to commerce.
The password used to connect to the server. Defaults to commerce.
The full data source to the connect to the database. If a dsn is supplied the driver/host/port and name are ignored. IF no dsn is supplied, one will will be constructed from driver/host/port and name.
This resets the checkout plugin search path to a namespace of your choosing, The default plugin search path is Handel::Checkout::Plugin::*
PerlSetVar HandelPluginPaths MyApp::Plugins
In the example above, the checkout plugin search path will load all plugins in the MyApp::Plugins::* namespace (but not MyApp::Plugin itself). Any plugins in Handel::Checkout::Plugin::* will be ignored.
You can also pass a comma or space separate list of namespaces.
PerlSetVar HandelPluginPaths 'MyApp::Plugins, OtherApp::Plugins'
Any plugin found in the search path that isn't a subclass of Handel::Checkout::Plugin will be ignored.
This adds an additional plugin search paths. This can be a comma or space separated list of namespaces.
PerlSetVar HandelAddPluginPaths 'MyApp::Plugins, OtherApp::Plugins'
In the example above, when a checkout process is loaded, it will load all plugins in the Handel::Checkout::Plugin::*, MyApp::Plugins::*, and OtherApp::Plugins namespaces.
Any plugin found in the search path that isn't a subclass of Handel::Checkout::Plugin will be ignored.
This is a comma/space separated list [or an anonymous array, or a regex outside of httpd.conf] of plugins to ignore when loading all available plugins in the given namespaces.
PerlSetVar HandelIgnorePlugins 'Handel::Checkout::Plugin::Initialize'
$ENV{'HandelIgnorePlugins'} = 'Handel::Checkout::Plugin::Initialize';
$ENV{'HandelIgnorePlugins'} = ['Handel::Checkout::Plugin::Initialize'];
$ENV{'HandelIgnorePlugins'} = qr/^Handel::Checkout::Plugin::(Initialize|Validate)$/;
If the Handel::Checkout::Plugin namespace has the following modules:
Handel::Checkout::Plugin::Initialize
Handel::Checkout::Plugin::ValidateAddress
Handel::Checkout::Plugin::FaxDelivery
Handel::Checkout::Plugin::EmailDelivery
all of the modules above will be loaded <b>except</b> Handel::Checkout::Plugin::Initialize. All plugins in any other configured namespaces will be loaded.
If both HandelLoadPlugins and HandelIgnorePlugins are specified, only the plugins in HandelLoadPlugins will be loaded, unless they are also in HandelIgnorePlugins in which case they will be ignored.
This is a comma or space separated list [or an anonymous array, or a regex outside of httpd.conf] of plugins to be loaded from the available namespaces.
PerlSetVar HandelLoadPlugins 'Handel::Checkout::Plugin::ValidateAddress'
$ENV{'HandelLoadPlugins'} = 'Handel::Checkout::Plugin::ValidateAddress';
$ENV{'HandelLoadPlugins'} = ['Handel::Checkout::Plugin::ValidateAddress'];
$ENV{'HandelLoadPlugins'} = qr/^Handel::Checkout::Plugin::(ValidateAddress|Authorize)$/;
If the following plugins are available in all configured namespaces:
Handel::Checkout::Plugin::Initialize
Handel::Checkout::Plugin::ValidateAddress
Handel::Checkout::Plugin::FaxDelivery
Handel::Checkout::Plugin::EmailDelivery
MyApp::Plugin::VerifiedByVisa
MyApp::Plugin::WarehouseUpdate
only Handel::Checkout::Plugin::ValidateAddress will be loaded. All other plugins in all configured namespaces will be ignored.
If both HandelLoadPlugins and HandelIgnorePlugins are specified, only the plugins in HandelLoadPlugins will be loaded, unless they are also in HandelIgnorePlugins in which case they will be ignored.
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/
| Handel documentation | view source | Contained in the Handel distribution. |