<%-- This is a PSP comment. It won't show up in the HTML or even in the class that this file will generate --%>

<%@ page imports = "sys,os,time"%><%-- Here's the modules that I need in this file. --%>
<%@ page imports = "PSP.Examples.PSPExamplePage" %>
<%@ page method="writeContent" %>
<%@ page extends="PSP.Examples.PSPExamplePage"%>

<%@ page indentType="braces" %>

<%--  Method declaration Test --%>
<psp:method name="title" params="">
return "PSP Tests Page - Braces"
</psp:method>

<h1 style="text-align:center;color:navy">Hello from PSP!</h1>

<%-- This image is served by WebKit --%>
<p style="text-align:center"><img src="psplogo.png" alt="Python Server Pages"></p>

<h4 style="text-align:center">This is the sample/test page<br>
for an implementation of<br>
<span style="color:navy">Python Server Pages</span>.</h4>

<p style="text-align:center"><span style="color:navy;background-color:yellow;padding:1pt 6pt">This version
of the test page uses <a href="Braces"><b>braces</b></a> as the indent type.</span></p>

<p style="text-align:center">Read the <a href="PSPDocs.psp"><strong>PSP documentation</strong></a>.
See the <a href="View.py?filename=<%=os.path.basename(self.request().serverSidePath())%>"><strong>source for this page</strong></a>.</p>

<p>The text below comes from another psp page which was inserted into this one with the <code>&lt;%@&nbsp;include&nbsp;%&gt;</code> directive.</p>

<div style="color:red"><%@ include file="my_include.psp" %></div>

<p>There are actually two ways to insert the contents of another file into a PSP page:</p>

<p>If you use <code>&lt;%@&nbsp;include&nbsp;file="somefile"&nbsp;%&gt;</code>, it will effectively insert the contents of the other file before class creation time.</p>

<p>Using <code>&lt;psp:include&nbsp;path="somefile"&gt;</code> will insert the output of the specified WebKit URL into the page <em>dynamically</em>.</p>

<div style="color:red"><psp:insert file="APSPinclude.html"></div>

<p>Time at which dynamic output was generated:</p>
<psp:include path = "APSPinclude.psp">

<h4>Below is a loop test:</h4>

<p>Loops are the trickiest part of PSP due to Python indentation for blocks syntax.</p>

<p style="color:navy">The use of braces, while not good for normal Python, does make things easier here where we are dealing with HTML.</p>

<%-- I still use indentation to make it easier to read. It just doesn't get passed through to Python. --%>
<ul><% for i in range(2): {  # loop #1, an automatic loop
    self.write('<li>Outer loop: ')
    self.write(i+1) %><ul>
    <% for j in range(2): { %><%-- loop #2, another automatic loop --%>
        <li>Inner loop: <%= j+1 %>
        <%self.write('(still in the inner loop)</li>')
    }  # end loop #2
    self.write('</ul></li>')
 }  # end loop #1
%></ul>

<hr>

<h4>Unix system info:</h4>
<table style="background-color:gray"><%
if os.name == 'posix': {
    for info, value in zip(('OS name', 'Hostname',
        'OS release', 'OS version', 'Hardware'), os.uname()): {
        res.write('<tr><td>' + info + ':&nbsp;</th>'
            '<td style="color:white">' + str(value) + '</td></tr>')
    }
} else: {
    res.write('<tr><td style="color:white">'
        'This is not a Unix system.</td></tr>')
}
%></table>

<hr>

<table>
<tr><th style="text-align:left">Path Info:</th><td><%=req.pathInfo()%></td></tr>
<tr><th style="text-align:left">extraURLPath:</th><td><%=req.extraURLPath()%></td></tr>
<tr><th style="text-align:left">Fields:</th><td><%= req.fields() %></td></tr>
<tr><th style="text-align:left">servletURI:</th><td><%= req.servletURI()%></td></tr>
<tr><th style="text-align:left">uriWebKitRoot:&nbsp;</th><td><%= req.uriWebKitRoot() %></td></tr>
<tr><th style="text-align:left">serverURL:</th><td><%= req.serverURL() %></td></tr>
<tr><th style="text-align:left">serverURLDir:</th><td><%= req.serverURLDir() %></td></tr>
</table>

<hr>

<h4>Request Variables:</h4>

<table><% for i, v in self.request()._environ.iteritems(): {
res.write('<tr style="vertical-align:top"><td style="color:red;font-size:small">'
    +str(i)+'&nbsp;</td><td style="color:blue;font-size:small">'
    +self.htmlEncode(v).replace(',', ',<wbr>').replace(';', ';<wbr>').replace(':/', ':<wbr>/')
    +'</td></tr>') } %></table>

<hr>

<h4>Comments:</h4>

<p>PSP comments will not show up in the source of the page.</p>

<p>Nothing should be visible here.</p>

<%-- Comment check --%><%-- # This kind not even in Python file created. --%>
<!-- Comment Check -->

<hr>

<h4>Testing a class method defined in the PSP code:</h4>

<%--  Method declaration test --%>
<psp:method name="testing" params="val">
self._response.write('<p>I\'m a method. <b style="color:maroon">%s</b></p>' % val)
</psp:method>

<%self.testing('Howdy!')%>

<hr>

<p><code>pass</code> can be used to end a block, so test that it can be used by itself too!</p>

<% pass %>

<p><i>If-Test:</i>
<%if 1: {%><b style="color:green">It's True</b><% }else: { %>It's false<% }%></p>

<hr>

<p><b>That's all, folks.</b></p>

<p><%= time.ctime()%></p>
