This file is indexed.

/usr/share/doc/python-myghty/html/globals.html is in python-myghty 1.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<html>
<head>
	<title>
Myghty Documentation
</title>
	<link href="style.css" rel="stylesheet" type="text/css"></link>
	<link href="syntaxhighlight.css" rel="stylesheet" type="text/css"></link>
</head>
<body>




<link href="docs.css" rel="stylesheet" type="text/css"></link>


<div style="position:absolute;left:0px;top:0px;"><a name="top"></a>&nbsp;</div>

<div class="doccontainer">

<div class="docheader">

<div class="docheadertext" >Myghty Documentation</div>
<div class="">Version: 1.1   Last Updated: 09/10/06 19:32:29</div>
</div>



		<A name="globals"></a>
		
	
<div class="topnav">


	
	<div class="topnavcontrol">
	View: <b>Paged</b> &nbsp;|&nbsp; <a href="documentation.html">One Page</a>
	</div>



<div class="topnavsectionlink">

<a href="index.html">Table of Contents</a>

<div class="prevnext">
Previous: <a href="scopedpython.html">Scoped <%python> Blocks</a>

&nbsp; | &nbsp;


Next: <a href="components.html">Components</a>

</div>
</div>


<div class="topnavmain">
	<div class="topnavheader">Standard Global Variables</div>
	<div class="topnavitems">
	


    
    
    <div class="toclink">
        <A style="" href="#globals_globalm">Your Best Friend: <i>m</i></a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#globals_globalargs">Your Other Best Friend: <i>ARGS</i></a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#globals_globalr">Your Pal: <i>r</i></a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#globals_globals">Your Fair Weather Friend: <i>s</i></a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#globals_globalcustom">Make your Own Friends</a>
    </div>
    
    <div class="toclinkcontainer">
        
        
    <div class="toclinkcontainer">
    
    <div class="smalltoclink">
    <A href="#globals_globalcustom_assignment">Assignment to Request-Scoped Globals</a>
    </div>

    </div>


    </div>



	</div>
</div>

</div>

		<div class="sectioncontent">
			




<div class="subsection" style="margin-left:10px;">

    <div class="sectiontext">


	<p>Myghty templates and components always have access to a set of global variables that are initialized on a per-request basis.  The Myghty request object <i>m</i> is always available, as are the component arguments <i>ARGS</i>.  When running with any HTTPHandler-based environment, the HTTP request object <i>r</i> is also available, which in mod_python is the actual mod_python request object, else it is a compatible emulating object.  The Myghty session object, or mod_python's own session object, may be configured to be available as the variable <i>s</i>.  Finally, any set of user-configured global variables can be defined as well; the value of these globals can be specified on a per-interpreter or per-request basis.</p>
	
	
			
	
			
	
			
	
			
	
				

    </div>

        



<A name="globals_globalm"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Your Best Friend: <i>m</i></span>
    <div class="sectiontext">


	<p><i>m</i> is known as the "request", which represents the runtime context of the template being executed.  Its not the same as the HTTP-specific request object <i>r</i> and is mostly agnostic of HTTP.  <i>m</i> includes methods for handling output and writing content, calling other components, as well as other services that a template will usually need.  The full list of request methods is described in <a href="request.html#request" >The Request</a>.
	</p>

	
    </div>


    <a href="#globals" class="toclink">back to section top</a>


</div>


        



<A name="globals_globalargs"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Your Other Best Friend: <i>ARGS</i></span>
    <div class="sectiontext">


	<p>ARGS represents a dictionary of all arguments sent to the current component.  While a component can specify arguments to be available in the component's namespace via the <%args> tag, the ARGS dictionary contains all arguments supplied to a component regardless of them being named in the <%args> section or not.</p>
	
	<p>In the case of a top-level component called in an HTTP context, ARGS contains the full set of client request parameters.  Each field is one of: a string, a list of strings, or for handling file upload objects, a Field object (from the FieldStorage API) or a list of Field objects.</p>
	
	<p>For components called by other components, ARGS contains all the arguments sent by the calling component. </p>
	
	<p>In all cases, the HTTP request arguments, or whatever arguments were originally sent to the request, are available via the request member <a href="request.html#request_members_request_args" >request_args</a>.

	<p>Component arguments are described in <a href="components.html#components_args" >Component Arguments - the &lt;%args&gt; tag</a>.</p>
	
    </div>


    <a href="#globals" class="toclink">back to section top</a>


</div>


        



<A name="globals_globalr"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Your Pal: <i>r</i></span>
    <div class="sectiontext">


	<p>When running Myghty with any of the HTTPHandlers, i.e. ApacheHandler, CGIHandler, WSGIHandler, or HTTPServerHandler,  variable <i>r</i> is a reference to either the mod python request object or a compatible emulation object.  In the case of ApacheHandler, it is the actual mod_python request.  In other cases, it attempts to provide a reasonably compatible interface, including the member variables headers_in, headers_out, err_headers_out, args, content_type, method, path_info, and filename (more can be added...just ask/submit patches).  The request object is useful applications that need awareness of HTTP-specific concepts, such as headers and cookies, beyond what the more generic <i>m</i> object provides which attempts to be largely agnostic with regards to HTTP.</p>
<p>
Under WSGIHandler, <i>r</i> also contains the member variables <span class="codeline">environ</span> and <span class="codeline">start_response</span>, so that an application may also have direct access to WSGI-specific constructs if needed.
</p>
	
    </div>


    <a href="#globals" class="toclink">back to section top</a>


</div>


        



<A name="globals_globals"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Your Fair Weather Friend: <i>s</i></span>
    <div class="sectiontext">


	<p><i>s</i> references the Myghty session object.  It can also be configured to reference the mod_python session object when running with mod_python 3.1   To use <i>s</i>, you need to turn it on via <a href="session.html#session_options_use_session" >use_session</a>.
	</p>
	<p>The Myghty session is still available even if <i>s</i> is not configured. See the section <a href="session.html#session" >Session</a> for full information on the session object.
	
    </div>


    <a href="#globals" class="toclink">back to section top</a>


</div>


        



<A name="globals_globalcustom"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Make your Own Friends</span>
    <div class="sectiontext">


	<p>Myghty supports the addition of any number of global variables that will be compiled into the namespace of all templates.  The value of these variables can be specified on a per-application basis or a per-request basis.  As of version 0.98, both scopes can be used simultaneously.  Per-application globals can be specified via the initial interpreter configurational parameters, or within the httpd.conf file in a mod_python environment.  Per-request globals require that the variables be initialized before the Myghty request begins, which requires programmatic "chaining" to the Interpreter via the methods described in <a href="programmatic.html#configuration_programmatic" >Programmatic Configuration</a>.
	</p>
	
	<p>The two configuration parameters to add global arguments are <span class="codeline">allow_globals</span>, which specifies a list of global variable names to compile into templates, and <span class="codeline">global_args</span>, which is a dictionary containing the names of the variables mapped to their desired values.  A basic example of programmatic global variables looks like:
	</p>

	

<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">WSGIHandler</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">application</span><span class="python_enclosure">(</span><span class="python_name">environ</span><span class="python_operator">, </span><span class="python_name">start_response</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_operator">    </span><span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">WSGIHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
        <span class="python_name">allow_globals </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'myglobal'</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
        <span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_literal">'/path/to/htdocs'</span><span class="python_operator">, </span>
        <span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/datadirectory'</span>
    <span class="python_enclosure">)</span><span class="python_operator">
    </span>
    <span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span>
            <span class="python_name">environ</span><span class="python_operator">, </span>
            <span class="python_name">start_response</span><span class="python_operator">,</span>
            <span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'myglobal' </span><span class="python_operator">: </span><span class="python_literal">'hi'</span><span class="python_enclosure">}</span>
    <span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>


        <p>Above, all Myghty components will have access to the global variable "myglobal" which has a per-request value of "hi".  Note that the <span class="codeline">allow_globals</span> parameter is only used on the first request, when constructing a new Interpreter object, whereas <span class="codeline">global_args</span> may be specified for each request.</p>

        <p>Another example, using Interpreter:</p>
        

<div class="code">
<pre><span class="python_name">interpreter </span><span class="python_operator">= </span><span class="python_name">interp</span><span class="python_operator">.</span><span class="python_name">Interpreter</span><span class="python_enclosure">(</span>
    <span class="python_name">allow_globals </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'myglobal'</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
    <span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'/path/to/datadir'</span><span class="python_operator">,</span>
    <span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">'/foo/components'</span><span class="python_operator">,</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">(</span><span class="python_literal">"file.myt"</span><span class="python_operator">, </span>
    <span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'myglobal'</span><span class="python_operator">:</span><span class="python_name">MyGlobalThingy</span><span class="python_enclosure">()}</span>
<span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>


        <p>Here is an ApacheHandler example which specifies globals within both scopes:</p>

        

<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">ApacheHandler </span><span class="python_keyword">as </span><span class="python_name">ApacheHandler</span><span class="python_operator">
</span>
<span class="python_comment"># create per-application global object</span>
<span class="python_name">appglobal </span><span class="python_operator">= </span><span class="python_literal">'myappglobal'</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_enclosure">)</span><span class="python_operator">:
    </span><span class="python_comment"># create per-request global object</span>
<span class="python_operator">    </span><span class="python_name">myglob </span><span class="python_operator">= </span><span class="python_name">MyGlobal</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_enclosure">)</span><span class="python_operator">
    </span>
    <span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">ApacheHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
            <span class="python_name">req</span><span class="python_operator">, </span>
            <span class="python_name">allow_globals </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'appglobal'</span><span class="python_operator">, </span><span class="python_literal">'myglobal'</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
            <span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'appglobal' </span><span class="python_operator">: </span><span class="python_name">appglobal</span><span class="python_enclosure">}</span>
    <span class="python_enclosure">)</span><span class="python_operator">
            </span>
    <span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_operator">, </span><span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'myglobal'</span><span class="python_operator">:</span><span class="python_name">myglob</span><span class="python_enclosure">})</span><span class="python_operator"></span></pre></div>


        <p>Here is an application-scoped global added in a mod_python environment via the httpd.conf file:</p>
	

<div class="code">
<pre># specify list of global variable names
PythonOption MyghtyAllowGlobals ['myglobal']

# specify the value of the global variable
PythonOption MyghtyGlobalArgs "{'myglobal':  \
    __import__('mystuff.util').util.MyGlobalThingy()}"</pre></div>


	
			
	
	
    </div>

        



<A name="globals_globalcustom_assignment"></a>

<div class="subsection" style="margin-left:30px;">

    <span class="sectionheadertext">Assignment to Request-Scoped Globals</span>
    <div class="sectiontext">


	<p>When the <span class="codeline">allow_globals</span> configuration parameter specifies global variables to be compiled into all templates, if the variable is not present at request time, it is assigned the value of <span class="codeline">None</span> (as of 0.98a).  This is handy for global variables whos value is not determined until within a request.
	</p>
	
	<p>To assign to a global variable, use <span class="codeline">m.global_args</span>:</p>
        

<div class="code">
<pre><span class="doctag"># assume the configuration parameter global_args = ['x','y','z'] is set
</span><span class="compcall">&lt;&amp; </span><span class="compname">hi </span><span class="compcall">&amp;&gt;</span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">global_args</span><span class="python_enclosure">[</span><span class="python_literal">'x'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'im x!'</span><span class="python_operator"></span>
<span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">global_args</span><span class="python_enclosure">[</span><span class="python_literal">'y'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'im y!'</span><span class="python_operator"></span>
<span class="compcall">&lt;&amp; </span><span class="compname">hi </span><span class="compcall">&amp;&gt;</span><span class="text">

</span><span class="deftag">&lt;%def</span><span class="compname"> hi</span><span class="deftag">&gt;</span><span class="text">
    x is '</span><span class="substitution">&lt;%</span><span class="python_operator"> </span><span class="python_name">x</span><span class="python_operator"> </span><span class="substitution">%&gt;</span><span class="text">'
    y is '</span><span class="substitution">&lt;%</span><span class="python_operator"> </span><span class="python_name">y</span><span class="python_operator"> </span><span class="substitution">%&gt;</span><span class="text">'
    z is '</span><span class="substitution">&lt;%</span><span class="python_operator"> </span><span class="python_name">z</span><span class="python_operator"> </span><span class="substitution">%&gt;</span><span class="text">'
</span><span class="deftag">&lt;/%def&gt;</span></pre></div>

	
	<p>this will produce:
	</p>
	
        

<div class="code">
<pre><span class="text">x is: ''
y is: ''
z is: ''
x is: 'im x!'
y is: 'im y!'
z is: ''</span></pre></div>
	
	
    </div>


    <a href="#globals" class="toclink">back to section top</a>


</div>





</div>




    
<div class="sectionnavblock">
<div class="sectionnav">


        Previous: <a href="scopedpython.html">Scoped <%python> Blocks</a>

                |

        Next: <a href="components.html">Components</a>

</div>
</div>


</div>


		</div>






</div>

















<center>
</center>
</body>
</html>