[Twisted-Python] Re: twisted pyblosxom

Moshe Zadka m at moshez.org
Mon May 12 06:47:12 EDT 2003


[CCing to the mailing list, which is the correct place to send questions to]

On Mon, 12 May 2003 18:37:19 +0800, Wari Wahab <wari at celestix.com> wrote:

> Wow, that's a fast reply :) Anyway, CGI does not work because:
...

I have a feeling that you're doing something strange, like using the
CGI module from inside the same process? Twisted Web runs CGIs just
like any other webserver does -- in a seperate process.

> Anyway, I'm really quite new to this, and I have no idea to make 
> pyblosxom a non-blocking resource. There are a few areas in pyblosxom 
> which is calculated intensively that makes pyblosxom somewhat blocking. 

There are a couple of classic tricks, which vary between deferred when
there's something specific you're waiting for or reactor.callLater loops
if you just want to break apart something big and reactor.callInThread
when it is too hard to break it apart.

> Another kludge I did was to return a blank string at the end of render() 
> although I did use request.write() all over.

It was probably better to request.finish() yourself, and
return server.NOT_DONE_YET.
 
> PS: If I were to make this run on port 80, how do I make twisted change 
> to a different user? I know it's possible with twisd and mktap commands, 
> just not sure on how to do it in an application.

The correct way is to write a -y'able file.

'''
# call this pybloxom.ypy
from twisted.internet import app
from twisted.web import server

root = CreatePyBloxomResource()
site = server.Site(root)
application = app.Application("pybloxsom", uid=33, gid=33)
application.listenTCP(80, site)
'''

Now use

twistd -y pybloxom.ypy

HTH
-- 
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/




More information about the Twisted-Python mailing list