[Pythonmac-SIG] pythonw from Apache

eichin at metacarta.com eichin at metacarta.com
Mon Mar 15 15:52:56 EST 2004


> Yes. You either need to be running apache as the logged-in user (obviously - the
> one with the active window manager ;) ) or use cgi-wrap.

On top of that, though, I've generally found that
  #!/usr/bin/pythonw
doesn't actually work, for the obvious reason: pythonw is itself a
shell script, and in a (lazy) attempt to avoid spinning in exec(),
unix systems have generally forbidden scripts as script-interpreters.

Instead, you need
  #!/usr/bin/env /usr/bin/pythonw
(or something similar, but that's generally the "portable" way to do
it, not that pythonw itself isn't macosx-specific anyway...)

I'm still not sure that gets you enough of a connection to "leak"
access from apache to your logged-in environment (iirc it isn't just
uids, but inhereted port-rights?) but at least it's a start.   A more
workable approach might be to have a pythonw script that you run (as a
StartupItem perhaps) that listens on a localhost-bound socket, and
have apache talk to that (using whatever mini-protocol is convenient,
possibly even soap or xmlrpc); this also gives you the advantage of
being able to have a control menu or status window for the app...



More information about the Pythonmac-SIG mailing list