Debian Codegraph @

sc/README

raw
1 Last updated: Sat Feb 18 23:42:29 EST 2006
2
3 NAME
4 CGI::Application::Standard::Config -- Define a standard configuration
5 API for CGI::Application
6
7 RATIONALE
8 This module defines a minimum standard interface that configuration
9 plugins for CGI::Application should meet. Having such a standard allows
10 other plugin authors to rely on basic configuration functionality
11 without coding exceptions for several configuration modules, or giving
12 up on such integration.
13
14 SYNOPSIS
15 For Average Users
16 Simply load the config plugin before other modules that might use it:
17
18 use CGI::Application::Plugin::ConfigAuto;
19 use CGI::Application::Plugin::Session;
20
21 For Configuration plugin authors
22 Configuration plugin authors only need to follow the standards
23 documented below.
24
25 For other plugin authors who wish to rely on the standard
26 Plugin authors who want to possibly use this standard can do so by
27 simply using this module:
28
29 package CGI::Application::Plugin::Session;
30 use CGI::Application::Standard::Config;
31
32 If a standards complaint config module hasn't already been loaded a stub
33 for config() will be added which will safely return "undef".
34
35 Example use by another plugin
36 Here code first tries to get configuration details first from a config
37 file, then from options passed to a plugin-specific config method, and
38 finally applies defaults if no configuration options are found.
39
40 my $session_options = $self->config('Session_options')
41 || $self->session_config()
42 || $self->session_defaults;
43
44 Standard Interface Definition
45 The following defines a minimum standard for configuration plugins to
46 meet.
47
48 Config plugins are free to provide to additional functionality.
49
50 Configuration plugins are also encourage to explicity document that they
51 are using "CGI::Application::Standard::Config".
52
53 If there are existing methods that follow the standard but have
54 different names, you can use this example to always export your method:
55
56 sub import {
57 my $app = caller;
58 no strict 'refs';
59 my $full_name = $app . '::config';
60 # Change cfg to your config()-compliant method name
61 *$full_name = \&cfg;
62 CGI::Application::Plugin::YourNameHere->export_to_level(1,@_);
63 }
64
65 $self->std_config
66 This method should be exported by default to simply declare that you
67 meet the standard report which version of the standard you meet. This
68 simple implementation is recommended:
69
70 sub std_config { return 1; }
71
72 $self->config
73 The intended use is to load to read-only configuration details once from
74 a config file at start up time.
75
76 This service is provided by plugins (list below). They must support at
77 at least this syntax:
78
79 my $value = $self->config('key');
80
81 By default, "config()" simply returns undef, making it safe for other
82 plugins to directly to check if "$self-"config('key')> returns the value
83 it needs.
84
85 config() must be exported by default.
86
87 For applications that need little configuration, config() is not
88 necessary-- using "PARAMS" in an instance script should suffice.
89
90 Also, the "param()" is the appropriate method to use to set a
91 configuration value at run time.
92
93 Configuration plugins that provide at least this basic API include:
94
95 CGI::Application::Plugin::ConfigAuto.
96
97 Standard config variables
98 Users are encouraged to use these standard config variable names, to
99 ease compatibility between plugins:
100
101 ROOT_URI - A URI corresponding to the project root (http://foo.com/proj )
102 ROOT_DIR - a file system path to the same location ( /home/joe/www/proj )
103
104 All-caps are used to denote that config variables are essentially global
105 constants.
106
107 Why URI and not URL? The wikipedia explains:
108
109 The contemporary point of view among the working group that oversees URIs is
110 that the terms URL and URN are context-dependent aspects of URI and rarely
111 need to be distinguished. Furthermore, the term URL is increasingly becoming
112 obsolete, as it is rarely necessary to differentiate between URLs and URIs,
113 in general.
114
115 Standard Version
116 This is 1.0 of the CGI::Application config() standard.
117
118 AUTHOR
119 Written by Mark Stosberg <[email protected]> with input from the
120 CGI::Application community.
121
122 COPYRIGHT and LICENSE
123 Copyright (C) 2008, Mark Stosberg. All rights reserved.
124
125 This library is free software; you can redistribute it and/or modify it
126 under the same terms as Perl itself.
127