[mod_python] changing publisher `content' before sent to client

Jorey Bump list at joreybump.com
Tue Jan 16 14:17:48 EST 2007


Jaime Wyant wrote:
> I must be missing something obvious here...
> 
> But, I want the publisher to continue mapping URLS like it is doing 
> now.  Is there some way to have the publisher do this, but automagically 
> call some other function (like index below) before doing a req.write?

It's impossible to know, without seeing your code (no, don't send it). 
How did you design your application? Are your calling functions using 
return to send the resulting page as a string (the typical approach), or 
are you using req.write statements (only necessary to improve 
performance in rare occasions)?

Why did you hardcode a hostname in the first place? It's easy to write a 
publisher application that is portable between hosts. You may be better 
off ripping the hostname out and making sure that your relative links 
are properly constructed. Or, you could pass the hostname as an argument.

As I mentioned, the typical approach with Publisher is to have a 
function return a string (the web page) to the browser. You can 
manipulate this string in the return statement to modify it, if you 
wish. If you want a 'quick fix' that involves tampering with mod_python 
or Apache internals, you are probably better off correcting the design 
flaws in your application instead.


More information about the Mod_python mailing list