[Twisted-Python] Congrats / a little newbie confusion

Peter Hansen peter at engcorp.com
Thu Apr 3 09:56:22 MST 2003


Jeffrey Mathews wrote:
> 
> First thing I notice is that the introductory demo doesn't work, because
> twistd.py won't run as a script (it has no "if __name__ == '__main__':
> run()").  I obviously could fix that, but it seems so basic that I worry
> that I'm just missing something (like I'm not supposed to be using the
> scripts in /scripts directly).

The files in twisted/scripts are not the ones you want to run... you need
to run the ones that were installed under c:\python22\scripts, or wherever
they go on your own machine.  Those basically do an imported from the 
twisted.scripts.xxx modules and call xxx.run(), so it amounts to almost
the same thing.

> Next question is what happened to support for a FieldStorage-like api in the
> protocols.http.request module?  Googling shows that 0.99.3 had it, but 1.03
> doesn't.  Is it coming back, or to be replaced by something else?  I'd like
> it for file uploads in a very simple web-based photo album, to share some
> family shots.

FieldStorage, as in the cgi module?  What don't you like about the request.args
field that is nicely parsed for you from the HTTP GET or POST request?  (Note
that the fields all come in as lists, so if you expect only one instance of
any given field you need to grab request.args['fieldname'][0] to get the
actual string value.)

> Thanks in advance for the help, and again, great job at PyCon.

I'm a rookie at Twisted, but I've just "been there" on both issues... good
fodder for a tutorial/FAQ I suppose... or a wiki.

-Peter




More information about the Twisted-Python mailing list