[mod_python] PSP

Julien Cigar jcigar at ulb.ac.be
Thu Jul 27 09:25:41 EDT 2006


I'm using PSP as a template engine (with SQLAlchemy and a home-made 

One thing which is _VERY_ annoying in PSP is that if a variable doesn't 
exist in the current global namespace, the script fails with a stack 
trace ... rather than output a blank for example.

I had resolved this problem partially with a custom function (a sort of 
templatetag) : http://rafb.net/paste/results/0BqTEk48.html
With this function I could do things like <%= 
access('invasive.scientific_name.name', globals()) %>, however this 
doesn't work with SQLAlchemy because the variable doesn't exists in the 
current namespace until it has been accessed (to avoid useless database 
accesses) ...

I think it will be a good idea to have a sort of access() function in 
the next mod_python release which output a blank (or ...) if the 
variable doesn't exist ..

Does anyone has an elegant solution to resolve this problem (other than 
a <% try: %> .... <% except: %> ... ?


Julien Cigar
Belgian Biodiversity Platform
Université Libre de Bruxelles
Campus de la Plaine CP 257
Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entrée ULB 2
B-1050 Bruxelles
office: jcigar at ulb.ac.be
home: mage at mordor.ath.cx

More information about the Mod_python mailing list