|
Tim Valenta
tonightslastsong at gmail.com
Mon Mar 9 20:50:11 EDT 2009
Which is why I spoke on the matter myself:>> >> >>> Make sure you set the content type to text/html instead of what the >> >> >>> default is. I don't think mod_python is going to do that part for >> >> >>> you. >> >> >>> >> >> >>> http://www.modpython.org/pipermail/mod_python/2006-November/022587.html >> >> >>> Tim On Mon, Mar 9, 2009 at 6:46 PM, Graham Dumpleton <graham.dumpleton at gmail.com > wrote: > The danger in overriding the Apache default content type, rather than > having the Python code self contained, is that when you try and run > your application in a different Apache environment it will stop > working until you realise that you had changed something outside of > the actual Python code to get it to work. > > Thus, changing the default in Apache can be considered bad practice as > far as portability and maintainability of code. It certainly isn't > something you want to do if trying to develop a product which you > expect other people would want to install. > > So, by all means do it in your own environment if you want to, but > please don't suggest it is a good thing for others to do, it isn't. > > Graham > > 2009/3/10 Tim Valenta <tonightslastsong at gmail.com>: > > All I'm saying is that it's case-specific. If you never need to be > > rendering plain text, and you're handling your JS/CSS whatever on your > own, > > then great. > > And if you want plain text at times, then just throw a req.content_type = > > "text/html" in some basic header include file. The end. :) > > Tim > > On Mon, Mar 9, 2009 at 5:21 PM, Clodoaldo Pinto Neto > > <clodoaldo.pinto.neto at gmail.com> wrote: > >> > >> 2009/3/9 Tim Valenta <tonightslastsong at gmail.com>: > >> >> Do not override the default Apache content type as it will effect the > >> >> whole server. > >> > > >> > And if that's what you want, then it's just as well. Anything that > >> > isn't text/plain would have to specify its type, and that'd be no > >> > different than if it were text/html instead. > >> > >> Not sure I understand what you mean. Plain text is rendered > >> inconveniently by the browsers if the content type is text/html, like > >> it will use a fancy font, in instead of fixed, and will not respect > >> new lines making most kinds of texts, like code, much harder or next > >> to impossible to read. > >> > >> Regards, Clodoaldo > >> > >> > But if your server isn't just running this new project, then don't > >> > change it, as Graham said. If it's your own thing, then do whatever > >> > you want, with the future in mind :) > >> > > >> > Tim > >> > > >> > On Mon, Mar 9, 2009 at 4:45 PM, Graham Dumpleton > >> > <graham.dumpleton at gmail.com> wrote: > >> >> > >> >> 2009/3/10 Tim Valenta <tonightslastsong at gmail.com>: > >> >> > I know I still did. I haven't used psp. You could set your > default > >> >> > Apache > >> >> > content type to be 'text/html' if you want, and then you wouldn't > >> >> > have to do > >> >> > it manually each time. But whatever fits your situation is best. > >> >> > >> >> Do not override the default Apache content type as it will effect the > >> >> whole server. > >> >> > >> >> PSP handler should already set req.content_type to 'text/html'. > >> >> > >> >> The publisher handler will try and guess whether returned content is > >> >> text/html if not explicitly set. This guess isn't done though where > >> >> req.write() is used, only being done where response is returned as > >> >> string from publisher function. The guessing code tries to determine > >> >> if it is HTML by looking at last 100 characters of the response and > >> >> seeing if it matches regex: > >> >> > >> >> re_html = re.compile(r"</HTML\s*>\s*$",re.I) > >> >> > >> >> If for some reason the closing HTML tag is missing or badly formatted > >> >> it will not know it is HTML. > >> >> > >> >> The safest way is always to set req.content_type explicitly. > >> >> > >> >> Graham > >> >> > >> >> > Tim > >> >> > > >> >> > On Mon, Mar 9, 2009 at 4:09 PM, Jordan Dunn <jdunn at nodetwo.org> > >> >> > wrote: > >> >> >> > >> >> >> do you have to set that if your using publisher instead of psp? |