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

Jaime Wyant programmer.py at gmail.com
Tue Jan 16 14:27:26 EST 2007

On 1/16/07, Jorey Bump <list at joreybump.com> wrote:
> 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)?

Maybe I did not explain things very well?  I am using mod_python.publisher,
which does its magic calling my functions automagically.  In my called
functions, I simply return a string.

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.

I hardcoded them because I sort of hacked this together about 4 or so years
ago --  you learn a lot in four years. Would I hardcode the server name
today - well no:).  (But this is not relevant to my question, imo).

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.

Yes, I'm quite aware of how the publisher works.  But the problem is, I have
this string scattered through a handful of modules.  Yeah, I'll fix them
correctly in the future.  For now I need a bandaid.  I have that bandaid, a
modified  copy of mod_python's publisher.py.

Yeah, it'd be better to fix the website, but I'm in a time crunch.  Plus,
publisher.py is well written / commented.  So plugging in my fix well was
simple - about 4 lines IIRC.  (Nice job mod_python developers!)

In the end, I guess there is no way to intercept the `req.write' call before
the publisher makes it.


"Government does not solve problems; it subsidizes them."
Ronald Reagan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070116/174487e9/attachment-0001.html

More information about the Mod_python mailing list