I generally agree, but if I were doing this, I might put my calculations in
awake() (making sure I call super) and have my PSPs override writeBody().
Or you could make a SitePage class whose awake() invokes self.calculate()
if that adds clarity.
This is just style, I guess.
-Chuck
At 12:02 PM 10/24/00 -0400, Geoff Talvola wrote:
>Can I just say that deriving a PSP from a servlet base class is great?
>It's a great way to separate the logic from the presentation. Put the
>data preparation in the servlet base class, and have that class call a
>method that you define in the derived PSP class.
>
>Here's a dumb but hopefully illustrative example of the kind of stuff
>I'm doing:
>
>----------
>MyPage.py:
>----------
>from Page import Page
>
>class MyReport(Page):
> def writeBody(self):
> # Do a bunch of database lookup and calculations in Python
> self.a = 123 + 456
> self.b = 5.123 * 98.7
>
> # Now render it using a psp "template"
> self.writeReport()
>
>----------
>MyPage.psp
>----------
><%@ page extends="MyReport" %>
><%@ page method="writeReport" %>
>
><b>Report:</b>
><br>a equals <%= self.a %>
><br>b equals <%= self.b %>
>
>
>
>--
>
>
>- Geoff Talvola
> Parlance Corporation
> gtalvola@...
>
>_______________________________________________
>Webware-discuss mailing list
>Webware-discuss@...
>http://lists.sourceforge.net/mailman/listinfo/webware-discuss
|