summaryrefslogtreecommitdiff
path: root/fml/doc/en/tutorial/internals/cgi.sgml
blob: 495694ec8a42497915986705bfb8d27762330701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!--
   $FML: cgi.sgml,v 1.1 2005/07/28 13:27:47 fukachan Exp $
-->


<chapter id="cgi.internal">
	<title>
	Internal Of CGI Process
	</title>


<sect1 id="cgi.internal.method">
	<title>
	Method
	</title>

<para>
FML::CGI class should implement the following methods:
<screen>
html_start()
run_cgi_main()
run_cgi_title()
run_cgi_navigator()
run_cgi_menu()
run_cgi_command_help()
run_cgi_options()
html_end()
</screen>
where
html_start() prints out the header of HTML such as DOCTYPE ... BODY,
html_end() prints /BODY and /HTML.
run_XXX methons prints the main content.
</para>

<para>
run() of $curproc method drives
<screen>
html_start()
run_cgi_XXX()
html_end()
</screen>
sequentially.
That is, the flow of CGI process is as follows:
<screen>
new()
prepare()
verify_request()
run()
   html_start()
   run_cgi_XXX()
   html_end()
finish()
</screen>
</para>

</sect1>


<sect1 id="cgi.internal.frames">
	<title>
	Screen Of CGI And The Method
	</title>

<para>
&fml8; CGI script creates the screen:
<screen>
          header
space     menu        space
bar 1     main        bar 2
space     menu        space
          footer
</screen>
The bar 1 and 2 are called as navigation bar.
</para>

<para>
html_start() generates header part(DOCTYPE ... BODY of HTML, NOT HTTP
HEADER).  html_end() generates footer part.
</para>

<para>
Instead, BODY content generates 3 x 3 tables by using methods drived
by run_cgi().
</para>

<para>
9 sub methods called by run_cgi() generetes the following 9 pieces on
the screen.
<screen>
nw   north  ne
west center east
sw   south  se
</screen>
</para>


<sect2>
	<title>
	Screen Of The Current CGI
	</title>

<para>
CGI screen generates 3 x 3 table structure.
The following methods generates the corresponding part of the screen.
<screen>
run_cgi_main
			run_cgi_title
run_cgi_navigator	run_cgi_menu	run_cgi_command_help
run_cgi_options
</screen>
These methods use TABLE to create 3 x 3 matrix.
These methods are defined in hash table.
run_cgi() executes them sequentially.
</para>

<para>
run_cgi_main() print nothing if nothing to do.
In almost cases, print just "OK ..." message.
If needed, it shows error messages.
run_cgi_main() runs before all other methonds to 
print out the latest information.
</para>

<para>
run_cgi_main() is adapter layer defined at FML::CGI::Menu::Admin.
Each command is executed via this layer.
</para>

<para>
In a few cases such as showing log, listing up addresses, 
run_cgi_menu() print out the data.
</para>

</sect2>

</sect1>


<sect1 id="cgi.internal.trampoline">
	<title>
	Screen And Trampolin Mechanism
	</title>

<para>
CGI print engine is moved to 
FML::Command:: class.
However FML::Command:: does not contains all content of print engine.
By object composition,
some modules use methods FML::CGI:: provides.
For example, subscribe command internal is as follows.
<screen>
FML::CGI::Admin::Main ->
FML::Command::Admin::subscribe ->
FML::CGI::Admin::User ->
SCREEN
</screen>
The flow goes and back again like trampolin mechanism.
</para>

</sect1>


<sect1 id="cgi.internal.problems">
	<title>
	MISC: Hard Coding Is Mandatory ?
	</title>

<para>
FML::CGI::Admin::User contains the relation between $comname and maps.
It is hard-coded. But it cannnot be avoided.
</para>

<para>
If we move the relation to configuration space, 
we need a lot of variables in it.
It is better to use configuration variables for cusotomization,
but ...
</para>

</sect1>


<!-- .cgi implementation -->
&sect.internal.cgi.examples;


</chapter>