PSP, Cheetah, PTL, ZOPE, etc ...

Tavis Rudd tavis at calrudd.com
Fri Aug 3 19:27:28 EDT 2001


Graham,

grahamd at dscpl.com.au (Graham Dumpleton) wrote in message 
> tavis at calrudd.com (Tavis Rudd) wrote in message 
> > Cheetah works with any type of data, not just text. It doesn't force
> > you to do anything like that.
> 
> The documentation when talking about placeholders says that if the value
> is not a string, it applies str() to it, or if the value is callable that
> it calls it and then applies str() to the result.

That's only for the final interpolation.  If you have a method that
returns a list of client objects and you want to iterate over that
list to create some HTML, here's how:
----------------------------------------------
<TABLE>
#for $client in $service.clients
<TR>
<TD>$client.surname, $client.firstname</TD>
<TD><A HREF="mailto:$client.email" >$client.email</A></TD>
</TR>
#end for
</TABLE>
----------------------------------------------
##compare this with PSP
<TABLE>
<% for client in service.clients(): %>
<TR>
<TD><%=client.surname()%>, <%=client.firstname()%></TD>
<TD><A HREF="mailto:<%=client.email()%>"><%=client.email()%></A></TD>
</TR>
<%end%>
</TABLE>
----------------------------------------------
Note: 
-You can turn off the auto-calling behaviour if you don't want it.  
-You can use a character sequence other than $ if you wish.
-You can do things like this:
   $myList[3:15],  $obj.meth($a*5, kwarg1=$b)

The docs are rather incomplete at the moment.  I'm about to upload the
latest version from the CVS, which is much more complete.  The
Velocity project (essentially Cheetah for Java) has some good
documentation at http://jakarta.apache.org/velocity/index.html

> I agree that *SP looks horrible and can become a mess. I think PSP in
> particular is potentially worse than others *SP implementations if one
> tries to use space or tab indenting ala Python style. Makes editing of
> the page potentially complicated.

The Webware implementation has some crafty ways around the indentation
problem, rendering it a non-issue.

> > > In the architecture I have, I guess I am uncomfortable about having code
> > > related to presentation mixed up in the service objects. 
> > > I suppose that
> > > some service objects may specifically relate to presentation, but in the
> > > main I would want to preserve the idea of services returning data related
> > > to the model, rather than a view of that model.
> > 
> > Ditto. That's exactly why I dislike PSP, PHP, etc. and is why we
> > created Cheetah.
> Huh? I am not sure your comment shows agreement with my thinking. I don't
> want presentation code in service objects as those service objects may be
> in totally distinct processes from where the web server engine is. 

Same here ... (quoting from the Cheetah Users' Guide)
=============================================
1.2 What is the philosophy behind Cheetah?

   Cheetah aims:
     * to make it easy to separate content, graphic design, and
program
       code.
       A clean separation makes it easier for a team of content
writers,
       HTML/graphic designers, and programmers to work together
without
       stepping on each other's toes and polluting each other's work.
The
       HTML framework and the content it contains are two separate
       things, and analytical calculations (program code) are another.
       Each team member should be able to concentrate on their
specialty
       and to implement their changes without having to go through one
of
       the others: i.e. the dreaded webmaster bottleneck.
       Other advantages to separation include:
          + faster development time.
          + HTML and program code that is easier to understand and
            maintain.
          + content that can be displayed in a variety of non-HTML
            formats such as PDF.
          + highly modular, flexible, and reusable site architectures.
...
=============================================
Like PSP, Cheetah doesn't require any presentation code in your
service objects.  That sort of stuff belongs in the template instead.

BTW, your documentation for OSE is excellent!!

Cheers,
Tavis



More information about the Python-list mailing list