Home | Wiki | OI 1.x Docs | OI 2.x Docs |
OpenInteract2::Config::GlobalOverride -- Process global override settings for a set of configuration directives
## ----------Sample of an override file---------- [Global] override_type = spops # Add a new value to 'user.track' [user.track.finalize] action = add value = 1 # Add two new entries to the ruleset for the 'news' object, giving # the system a hint as to what type of data it should be [news.rules_from] action = add value = OpenInteract2::RSSArticleSummarize value = OpenInteract2::EditorApproval type = list # Remove 'SPOPS::Secure' from 'page.isa' list [page.isa] action = remove value = SPOPS::Secure # Remove key and value for 'uid' from 'user.field_map' hash [user.field_map] action = remove value = uid # Remove the entire 'field_alter' hashref [user.field_alter] action = remove # Replace 'SPOPS::DBI::MySQL with 'SPOPS::DBI::Pg' in all keys that # have an 'isa' entry [*.isa] action = replace replace = SPOPS::DBI::MySQL value = SPOPS::DBI::Pg # Replace 'SPOPS::DBI::MySQL with 'SPOPS::DBI::Sybase' in the # 'user.isa' list [user.isa] action = replace replace = SPOPS::DBI::MySQL value = SPOPS::DBI::Sybase ## ----------End sample override file----------
## Read in a configuration and apply the override file, saved for ## this example in global_override.ini my $config = OpenInteract2::Config->new( 'ini', { filename => 'server.ini' } ); my $override_file = join( '/', $config->{dir}{config}, 'global_override.ini' ); my $override = OpenInteract2::Config::GlobalOverride->new( $override_file ); $override->apply_rules( $config ); ## Values in $config are now modified based on the given rules
This class allows you to define a set of override rules and apply them to a configuration. This is very helpful in OpenInteract because large sections of the server configuration are pieced together from information in a number of packages. Since there can be any number of packages -- at least 14, and most likely more -- modifying each of these is time-consuming and error-prone. Additionally, you need to modify the configuration for a package every time you upgrade.
Instead of this hassle, you can now define rules in a single file that will modify any configuration value. You have three ways to do this:
add: Add/overwrite a value to an existing list or hash.
remove: Remove a particular value from a list, or delete a hash key.
replace: Replace a value with another in a list.
new( $rule_filename )
apply_rules( $config )
None known.
Nothing known.
Copyright (c) 2002-2003 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chris Winters <chris@cwinters.com>
Generated from the OpenInteract 1.99_03 source.