[mod_python] modpython psp v. spyce

Sterling Hughes sterling at apache.org
Sun Mar 7 11:22:14 EST 2004

On Mar 7, 2004, at 11:07 AM, Doug Holton wrote:

>> Newbie here. Before Grisha released psp, I started using Spyce with 
>> apache/python.  I'm really still new to python, apache etc.  not a 
>> web guy by training.  I've been skimming the group archives to see 
>> some comparisons of Spyce and Grisha's PSP.
>> Can someone give some insight into how these two approaches compare?  
>> Is there a reason for both to exist?
> Like others have mentioned, PHP mixes code in with HTML can get messy. 
> One solution in PHP is to use the Smarty templating system to separate 
> the view (the html) and the data (like the results of a database query 
> for example).
> It looks like you can do something similar with PSP or Cheetah but not 
> Spyce.  See "Using PSP as a Templating System" here:
> http://www.onlamp.com/pub/a/python/2004/02/26/python_server_pages.html
> Smarty, PSP, and Cheetah have speed optimizations too: they can cache 
> a parsed template so that it only has to be parsed once. See the 
> PSPDbmCache option to make PSP cache to files instead of using up 
> memory.
> A possible disadvantage of PSP though is that it is tied to 
> mod_python, whereas Spyce or other frameworks like Quixote can be used 
> with or without mod_python.

The general philosophy of people writing php code on large sites (or 
experienced PHP programmers) is that "php is my templating language."  
Mixing PHP code with HTML is not at all messy - what's messy is mixing 
backend interface logic with frontend logic.   Generally, in PHP, i 
have a little template class that works akin to this small function:

function template_include($file, $params)

And that's how I separate my backend and frontend logic.  I use the PHP 
processor, but I restrict what I put in my template.  This is not only 
an order of magnitude faster than a solution like Smarty, but its just 
as clean from an interface perspective.

PSP takes the same approach.  Its not about encouraging you to mix 
backend and frontend logic - although it certainly makes it easier.  
Its about providing an efficient templating solution "out-of-the-box," 
and without the extra layer of complexity.  Frontends are simple, 
writing a templating language, or mini-language on top of python just 
adds unnecessary complexity.


More information about the Mod_python mailing list