David Casti wrote:
> This may be an FAQ, but I can't find it on the Wiki or in my
> archives of
> the discussion list.
> My company has version 1 of our billing system written in
> PSP. We've had
> some success with the product, and are in the process of
> finishing version
> 2. The question is: Should we stick with PSP, or go to
> Servlets? A more
> general question might be: What are the different
> circumstances to pick PSP
> or Servlets?
> The key advantages of PSP for us is that we can have
> programmers and HTML
> designers working on the same HTML files. The HTML guy does all the
> markup, and the programmer comes through and inserts form controls,
> includes banners, etc. Since the majority of the page is
> static HTML with
> a few dynamically-generated controls, PSP seems to be the way
> to go. From
> the examples, it looks like this would be difficult or
> impossible to do
> with Servlets.
> The key advantage of Servlets seems to be that they are
> objects which can
> be included, methods overriden, inherited from, etc. If PSP
> files could
> inherit from each other, then I'm not aware of any advantages
> of Servlets.
Except that it will always be more natural and confortable to edit Python
code in the form of a regular Python source file than it will be to edit it
in the form of a PSP file, IMHO. That's the advantage of a servlet -- it's
a regular Python source file. You can import it, instantiate the servlet,
play around with it, etc. even outside of Webware.
> I don't think I really understand what is going on for this
> reason: Almost
> all the discussion, documentation, examples, etc. are
> Servlets. So, I get
> the feeling I must be missing the boat here. :) Can someone
> enlighten me?
I think you nailed it -- PSP is much nicer for pages which are mostly HTML
with just a little bit of supporting Python code. Servlets are better for
things which are mostly code with just a little bit of HTML (or none at
You can get the best of both worlds by having a servlet base class with a
PSP that inherits from the base class. That's what I do when I have pages
with both a fair amount of supporting Python code and a lot of HTML markup.
(In fact, almost all of my PSP pages have a corresponding servlet base class
with stuff like SQL queries and data massaging. The PSP itself generally
just renders the data that was prepared by a method or methods in the base
When I'm creating a new page, I'll usually go ahead and create both an
"empty" PSP and an "empty" Servlet that is the PSP's base class. Then I'll
start putting the "preparation" methods into the Servlet, and the rendering
into the PSP. You might try working like that.
(Of course, all of my servlets inherit from a "SecurePage" which in turn
inherits from "SitePage" which inherits from "Page". I also have other
specialized base classes like "ReportPage" for particular types of pages.)
PSP does have 2 limitations currently. As you pointed out, it might be nice
to have PSP files be able to inherit from each other. And it would be nice
for PSP files to be able to define additional methods in PSP syntax besides
the "main" method. Neither of these has been a real problem for me but I
would like to see these limitations removed some day.