Mercurial > cgi-bin > hgweb.cgi > tincan
diff 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 |
line wrap: on
line diff
--- a/code_behind.html Mon May 13 21:24:48 2019 -0700 +++ b/code_behind.html Wed May 15 00:00:45 2019 -0700 @@ -15,7 +15,7 @@ file names match while only the extensions differ; e.g. <var>foo.py</var> will contain the code-behind logic associated with <var>foo.pspx</var>. Use of the <code>#python</code> and/or <code>#template</code> header - directives will of course change this default association.</p> + directives can of course change this default association.</p> <p>Pretty much anything can be in the code-behind files, with one restriction. There must be one and only one instance of a subclass of either <var>Page</var> (normal pages) or <var>ErrorPage</var> (error @@ -42,6 +42,21 @@ method; the default behavior as described in the <em>Default Template Variables</em> section of the template documentation is normally sufficient.</p> + <h3>Page Objects</h3> + <p>These contain the code-behind for normal pages. When the <var>handle</var> + method begins executing, they contain two instance variables: <var>request</var> + (a <var>bottle.Request</var> object) and <var>response</var> (a <var>bottle.Response</var> + object). </p> + <h3>ErrorPage Objects</h3> + <p>These contain the code-behind for error pages. When the <var>handle</var> + method begins executing, they contain two instance variables: <var>request</var> + (a <var>bottle.Request</var> object) and <var>error</var> (a <var>bottle.HTTPError</var> + object). </p> + <h3>The Application Context</h3> + <p>There is no separate standard instance variable in either <var>Page</var> + or <var>ErrorPage</var> that provides such, because it is available via + <var> request.app</var>. See the Bottle documentation for more + information.</p> <h2>Code-Behind is Optional</h2> <p>If you define a template with no code-behind file, TinCan will use either <var>Page</var> or <var>ErrorPage</var> as appropriate, which will