comparison code_behind.html @ 11:8037bad7d5a8 draft

Update documentation, fix some #forward bugs.
author David Barts <n5jrn@me.com>
date Wed, 15 May 2019 00:00:45 -0700
parents 84998cd4e123
children
comparison
equal deleted inserted replaced
10:84998cd4e123 11:8037bad7d5a8
13 <p> In the main webapp tree (i.e. not in <var>WEB-INF</var>), files ending 13 <p> In the main webapp tree (i.e. not in <var>WEB-INF</var>), files ending
14 in a <var>.py</var> extension contain code-behind logic. By default, the 14 in a <var>.py</var> extension contain code-behind logic. By default, the
15 file names match while only the extensions differ; e.g. <var>foo.py</var> 15 file names match while only the extensions differ; e.g. <var>foo.py</var>
16 will contain the code-behind logic associated with <var>foo.pspx</var>. 16 will contain the code-behind logic associated with <var>foo.pspx</var>.
17 Use of the <code>#python</code> and/or <code>#template</code> header 17 Use of the <code>#python</code> and/or <code>#template</code> header
18 directives will of course change this default association.</p> 18 directives can of course change this default association.</p>
19 <p>Pretty much anything can be in the code-behind files, with one 19 <p>Pretty much anything can be in the code-behind files, with one
20 restriction. There must be one and only one instance of a subclass of 20 restriction. There must be one and only one instance of a subclass of
21 either <var>Page</var> (normal pages) or <var>ErrorPage</var> (error 21 either <var>Page</var> (normal pages) or <var>ErrorPage</var> (error
22 pages).</p> 22 pages).</p>
23 <h2>BasePage Objects</h2> 23 <h2>BasePage Objects</h2>
40 and define classes as you see fit in the code-behind.</p> 40 and define classes as you see fit in the code-behind.</p>
41 <p>Note that it is not normally necessary to override the <var>export</var> 41 <p>Note that it is not normally necessary to override the <var>export</var>
42 method; the default behavior as described in the <em>Default Template 42 method; the default behavior as described in the <em>Default Template
43 Variables</em> section of the template documentation is normally 43 Variables</em> section of the template documentation is normally
44 sufficient.</p> 44 sufficient.</p>
45 <h3>Page Objects</h3>
46 <p>These contain the code-behind for normal pages. When the <var>handle</var>
47 method begins executing, they contain two instance variables: <var>request</var>
48 (a <var>bottle.Request</var> object) and <var>response</var> (a <var>bottle.Response</var>
49 object). </p>
50 <h3>ErrorPage Objects</h3>
51 <p>These contain the code-behind for error pages.&nbsp; When the <var>handle</var>
52 method begins executing, they contain two instance variables: <var>request</var>
53 (a <var>bottle.Request</var> object) and <var>error</var> (a <var>bottle.HTTPError</var>
54 object). </p>
55 <h3>The Application Context</h3>
56 <p>There is no separate standard instance variable in either <var>Page</var>
57 or <var>ErrorPage</var> that provides such, because it is available via
58 <var> request.app</var>. See the Bottle documentation for more
59 information.</p>
45 <h2>Code-Behind is Optional</h2> 60 <h2>Code-Behind is Optional</h2>
46 <p>If you define a template with no code-behind file, TinCan will use either 61 <p>If you define a template with no code-behind file, TinCan will use either
47 <var>Page</var> or <var>ErrorPage</var> as appropriate, which will 62 <var>Page</var> or <var>ErrorPage</var> as appropriate, which will
48 present the standard, minimal set of variables to your template.</p> 63 present the standard, minimal set of variables to your template.</p>
49 <h2>Code-Behind Files Are Not Standard Modules</h2> 64 <h2>Code-Behind Files Are Not Standard Modules</h2>