Is there a way for PHP to pass HTML form variables (POST) directly to a python script called with "passthru" in PHP without PHP having to know the variable names?
Can PHP pass the HTTP POST request to python so that i.e. the cgi
module in python will read it like it was passed "from the web"?
Basic setup: Joomla CMS, with the jumi module.
NB! Python 2.4, PHP 5.3.3 on RedHat 5.9 - only standard packages.
One of the jumi applications is a python script which creates a form, and also handles the POST variables.
Reason: A lot more python knowledge in our shop, and the python script does a lot in the background.
In the jumi PHP script I have:
<?php
$var1 = $_REQUEST['myVar1'];
$var2 = $_REQUEST['myVar2'];
echo passthru('/usr/bin/python /var/www/html/joomla/jumi/portal-ldap.py '.$myVar1.' '.$myVar2);
?>
The python scripts then uses sys.arvg
to process these variables.
It works - by all means, but it also means that any additinal variables must be known to both scripts.
Is there a way for PHP to pass the form variables directly to the python script in a way so that the "cgi" module in Python can process the variables as it would if I ran the python script with a framework/cgi/mod_python/...?
Python handling form variables:
import cgi
form = cgi.FieldStorage()
var1 = form.getvalue("myVar1", "nothing")
var2 = form.getvalue("myVar2", "nothing")