Jorey Bump
list at joreybump.com
Tue Jan 16 12:51:29 EST 2007
Jaime Wyant wrote: > Hi all. I was not sure of a good subject, but I think this is close. > Here is what I want to do: > > * Use publisher handler. > * "Grab" data before it is sent to the client, perform some `string > substitution' , send modified string / data onto the client. > > I made a copy of publisher.py and now use a modified version which > performs the necessary string changes before doing req.write. But, I > can't help but think that there is a cleaner way to do this. Is there a > `better' way? Ordinary python string replacement is available in the returned result: def index() body = """ <html> <head> <title>%s</title> </head> <body> %s </body> </html> """ title = "This is the Title" content = "<p>This is the content</p>" return body % (title, content) Or did you have something else in mind?
|