<%-- 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 --%> return "PSP Tests Page - Braces"

Hello from PSP!

<%-- This image is served by WebKit --%>

This is the sample/test page
for an implementation of
Python Server Pages.

This version of the test page uses braces as the indent type.

Read the PSP documentation. See the source for this page.

The text below comes from another psp page which was inserted into this one with the <%@ include %> directive.

<%@ include file="my_include.psp" %>

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

If you use <%@ include file="somefile" %>, it will effectively insert the contents of the other file before class creation time.

Using <psp:include path="somefile"> will insert the output of the specified WebKit URL into the page dynamically.

Time at which dynamic output was generated:

Below is a loop test:

Loops are the trickiest part of PSP due to Python indentation for blocks syntax.

The uses of braces, while not good for normal Python, does make things easier here where we are dealing with HTML.

<%-- I still use indentation to make it easier to read. It just doesn't get passed through to Python. --%>

Unix system info:

<% if os.name == 'posix': { for info, value in zip(('OS name', 'Hostname', 'OS release', 'OS version', 'Hardware'), os.uname()): { res.write('') } } else: { res.write('') } %>
' + info + ': ' '' + str(value) + '
' 'This is not a Unix system.

Path Info:<%=req.pathInfo()%>
extraURLPath:<%=req.extraURLPath()%>
Fields:<%= req.fields() %>
servletURI:<%= req.servletURI()%>
uriWebKitRoot: <%= req.uriWebKitRoot() %>
serverURL:<%= req.serverURL() %>
serverURLDir:<%= req.serverURLDir() %>

Request Variables:

<% for i in self.request()._environ.keys(): { res.write('') } %>
' +str(i)+' ' +self.request()._environ[i].replace( ',', ',').replace(';', ';').replace(':/', ':/') +'

Comments:

PSP comments will not show up in the source of the page.

Nothing should be visible here.

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

Testing a class method defined in the PSP code:

<%-- Method declaration test --%> self._response.write('

I\'m a method. %s

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

pass can be used to end a block, so test that it can be used by itself too!

<% pass %>

If-Test: <%if 1: {%>It's True<% }else: { %>It's false<% }%>


That's all, folks.

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