Python: popen problems

Hello I'm writing a web server in python(obelisk-http.sourceforge.net)
and I'm having a greeat problem with POST method it like that

When someone make a POST request to the server it must open the executable(perl/python/.exe/elf) and send to the STANDART in (stdin) the request and get the response.

when i send the request to stdin of any binarie(.exe or elf) works

but when i try to use a script it don't read the stdin I'm using a code like that

import os,sys
from subprocess import Popen,PIPE 

try:
    stdin, stdout = os.popen2("script.py")
except:
    exit(1)
stdin.write("Hello World!")
stdin.close()
print stdout.read()
stdout.close()

script.py:

print raw_input() #just read from stdin and send to stdout

ok, but it don't work :\

someone have an ideia?

What error are you getting? It will be difficult to help you unless you share information like that. I tried the first bit of code that you've supplied, and it works fine on a terminal.

try:
    stdin, stdout = os.popen2("python script.py")
except:
    exit(1)
stdin.write("Hello World!")
stdin.close()
print stdout.read()
stdout.close()
    

you are also not using the methods you imported from subprocess..I assume you are going to used them later?
thesubprocess s module in later Python version is meant to replace os.popen* and other older methods.
last point : its better to structure your script.py so that you can import them into your script, instead of calling them from the shell..an example of what i mean
script.py

def printstdin():
    return raw_input()

then from your main script, you do:

import script

then you can use printstdin().