Gregory Trubetskoy
grisha at modpython.org
Thu Dec 28 13:15:08 EST 2000
Try this: def say(req, what="NOTHING"): req.content_type = "text/html" return "I am saying %s" % what This is sort of a "bug"... The publisher handler attempts to guess the content_type, but *only* it isn't set already. Depending on your configuration, Apache may take the liberty of setting it (in mod_negotation for example). So far I haven't figured out a clean solution to this. Grisha On Thu, 28 Dec 2000, Emmanuel. M. Decarie wrote: > Hello, > > I just tried the publisher handler with the "hello.py" example found > in the manual: > > > > >""" Publisher example """ > > > >def say(req, what="NOTHING"): > > return "I am saying %s" % what > > http://www.modpython.org/live/mod_python-2.7.1/doc-html/hand-pub-intro.html > > Its working fine. But I didn't find a way to send some HTML. The > publisher handler seems to always return "Content-Type: text/plain". > How can I tell it to return "Content-Type: text/html". > > When I put at the top of the file "hello.py" this line: > > from mod_python import apache > > it look like that I can read the req object, but that I can't set values. > > For example, If I rewrite the hello.py example: > > from mod_python import apache > > def say(req, what="NOTHING"): > req.content_type = "text/html" > req.send_http_header () > req.write (what) > return apache.OK > > And then try to access /hello.py/say, Apache is not serving the page. > > I'm fairly new to Python, Apache and mod_python, so its a lot to swallow. > > I'm using FreeBSD 4.0 and mod_python 2.7.1 and Python 2.0. > > I like the way the publisher handler work, but I really need to have > control on the HTTP headers returned by mod_python to be able to > choose to publish plain text, html, or do redirection, send 404 code > and so on. > > TIA > > Cheers > > -Emmanuel > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Emmanuel Décarie - Consultant > Programmation pour le Web - Programming for the Web > UserLand Frontier - Perl - JavaScript - AppleScript - HTML - XML > http://www.scriptdigital.com > > ---> The Frontier Newbie Toolbox: > <http://www.scriptdigital.com/fnt/frontierNewbieToolbox.html> > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://www.modpython.org/mailman/listinfo/mod_python >
|