passing information to mod_wsgi and returning to div tag
long time reader first time poster.
I've recently been tasked with incorporating some python into a webpage for my employer. After doing some research it seemed that mod_wsgi and Django were the way to go, and it seemed to work great. However, my employer would like to maintain the site in Drupal and incorporate python as such I don't think the Django (or any other python framework) is viable as there would be two competing frameworks running around. I've managed to setup a wsgi-scripts bin and can get python code to run however开发者_运维技巧 I have run into a few problems:
1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method?
2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page.
Thanks, Paul
Drupal is a PHP-language framework, and wsgi/Django are waay too heavy for you IMHO. They're kinda designed to be used for the whole website.
How about passthru in php?
passthru — Execute an external program and display raw output
You could execute the python script (maybe even with command line arguments from POST) and display raw HTML that the script outputs.
1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method?
This makes no sense out of context.
If Apache (or whatever web server you're using) runs mod_wsgi, which runs Python, then the answer is "This is not only the standard, it's absolutely all you've got. Outside environment variables."
I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple.
2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page.
"have the script return to a div environment" doesn't make any sense at all.
"Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page." Doesn't make any sense at all. You seem to be describing something that's not HTTP at all.
I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple.
A request (GET, POST, PUT, DELETE, whatever) goes to the web server and a page comes back. That's more-or-less HTTP in a nutshell. There are no other inputs. There are no partial outputs.
If you want a Python application (running under mod_wsgi) to get data from Drupal, that's just an API call from Python to whatever server is running Drupal.
If you want the old page plus new information to be displayed, you have to assemble a page which contains the old page plus the new information. You have to write this new page. Use a template or some other tool.
精彩评论