Python refuses text.replace() in one environment
- by gx
Hi fellow programmers,
I've been mocking about with the following bit of dirty support-code for a pylons app, which works fine in a python-shell, a separate python file, or when running in paster. Now, we've put the application on-line through mod_wsgi and apache and this specific piece of code stopped working completely. First off, the code itself:
def fixStyle(self, text):
t = text.replace('<p>', '<p style="%s">' % (STYLEDEF,))
t = t.replace('class="wide"', 'style="width: 125px; %s"' % (DEFSTYLE,))
t = t.replace('<td>', '<td style="%s">' % (STYLEDEF,))
t = t.replace('<a ', '<a style="%s" ' % (LINKSTYLE,))
return t
It seems pretty straightforward, and to be honest, it is. So what happens when I put a piece of text in it, for example:
<table><tr><td>Test!</td></tr></table>
The output should be:
<table><tr><td style="stuff-from-styledef">Test!</td></tr></table>
and it is, on most systems. When we put it through the app on Apache/mod_wsgi though, the following happens:
<table><tr><td>Test!</td></tr></table>
You guessed it.
I'm currently at a loss and have no idea where to go next. Googling doesn't really work out, so I'm hoping on you guys to help out and perhaps point out a fundamental issue with using whatever-is-causing-this.
If anything is missing I'll edit it in.