Since the new build has been delayed, I am going to check in my changes=20=
unless anybody objects. Here are my changes. The first one may affect=20=
others.
=95 I've changed the implementation of compiled PSP pages so the=20=
writeHTML(trans) method doesn't do the actual work, but rather it calls=20=
another method, _writeHTML( fileLikeObj ) which does the work but=20
doesn't take a transaction. This is so the PSP unit tests don't need=20
to emulate transactions. The only way this might affect people is if=20
they rely on the 'req' and 'trans' variables that PSPPage sets. You=20
can replace those vars with self.request() and self.transaction() and=20
everything should be fine.
=95 I've added two features to PSP, <psp:file> and <psp:class>. =
Below=20
is the description that I added to the documentation.
=95 There were problems with the adjusting of indentation when =
the PSP=20
files were written in Macintosh format, i.e. with \r at the end of=20
lines instead of \n. I added test cases for it, and fix the problems.
=95 Converted test for these components to unittests:
- PSP
- WebUtils
- TaskKit
- half of MiscUtils
- UserKit (but has failures)
=95 Added a file, AllTests.py, which calls unit tests for all =
components.
=95 Fixed style sheet for documentation--a lot of indentation =
was messed=20
up.
Incidentally, I have to commend the people who wrote the PSP code. It=20=
is very clean, and easy to understand. And this one part is the only=20
dependency on the rest of Webware.
-winston
------------------------
File and Class Level Script Tags
"<psp:file>" and "<psp:class>"
The file and class level script tag allows you to write Python code at=20=
the file (module) level or class level. For example, at the file level,=20=
you might do imports statements, and some initialization that occurs=20
only when the PSP file is loaded the first time. You can even define=20
other classes that are used in your PSP file.
Example
<psp:file>
# Since this is at the module level, _log is only defined once for=20
this file
import logging
_log =3D logging.getLogger( __name__ )
</psp:file>
<html>
<% _log.debug('Okay, Ive been called.') %>
<p>Write stuff here.</p>
</html>
Example
At the class level you can define methods using ordinary python syntax=20=
instead of the <psp:method > syntax below.
<psp:class>
def writeNavBar(self):
for uri, title in self.menuPages():
self.write( "<a href=3D"%s">%s</a>" % (uri, title) )
</psp:class>
Indentation is adjusted within the file and class blocks. Just make=20
your indentation consistent with the block, and PSP will adjust the=20
whole block to be properly indented for either the class or the file.=20
For example file level Python would normally have no indentation. But=20
in PSP pages, you might want some indentation to show it is inside of=20
the <psp:file>...</psp:file> tags. That is no problem, PSP will adjust=20=
accordingly.
There is one special case with adding methods via the <psp:class> tag.=20=
The awake() method requires special handling, so you should always use=20=
the <psp:method> tag below if you want to override the awake() method.
The <psp:file> and <psp:class> tags were added to Webware v0.91=
|