473,473 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Difference in coding for mod_python, CGI python, the regular python interpreter, etc

16 New Member
I'm looking at Python and noticed that there's a few way's to use Python for web development.

If I write some code for a system using mod_python will it run unaltered in CGI mode and from the interpreter? Or are modifications required? If so, how drastic?

Thanks for your time.
Dec 17 '07 #1
3 1603
oler1s
671 Recognized Expert Contributor
So, CGI is a specification, and part of it explains how CGI programs are written. CGI programs are just like ordinary programs on your computer. Can your computer run it? Then it can be made into a CGI. (Well, more accurately, it needs to be able to output to stdout or something, but those details go offtopic).

Ok, it’s a bit more complicated than that. CGI programs, if you want them to be useful, need to deal with all the requirements of CGI. For one thing, the output needs to be formatted a certain way. Command line arguments are actually used by CGI for another purpose, so you rely on environment variables. Etc etc. You can google up “Python CGI”, “CGI”, and all those things, and they’ll teach you how to write CGIs. Obviously, the CGI tutorials designed specifically for Python will be easiest to understand.

mod_python is different. It’s specifically for Apache, because what mod_python does is it integrates tightly with Apache and intercepts chosen requests. See, when a request for a webpage is made, Apache normally deals with it in several processing steps (phases). mod_python provides and allows you to provide handlers for various phases, in place of Apache’s. Kinda neat, as you aren’t limited to writing programs anymore. You can modify content, etc.. Of course, you can also use this capability to have Apache serve your python programs instead. mod_python is a generic system for having Python deal with handlers, and that’s why there’s more configuration work involved in getting mod_python to work with Python code.
Dec 18 '07 #2
Hero Doug
16 New Member
Thanks for the reply oler1s.

It seem's that python may not be the most web friendly when it come to setting up an environment.

My biggest concern was knowing how portable the code I write would be. It would be ideal to use the code I write in a desktop app or on the web without modification.

By the sounds of it using Python on the web shouldn't be too difficult. I'm thinking a specialized front-controller to access the business logic.
Dec 18 '07 #3
oler1s
671 Recognized Expert Contributor
It seem’s that python may not be the most web friendly when it come to setting up an environment.
True, that crown is fit for PHP. It was designed very much as a web-centric language, and everything from the language to setting up the environment (at least with an Apache based stack) is very easy.

Python has gained a lot of popularity recently with the release of web frameworks like Turbogears and Django, and more. All these frameworks make web development very easy, and combat some of the (perceived?) problems with PHP. That and Python itself is a very beginner friendly language.

If you’re looking to get into web development with Python, don’t discount the various web frameworks for Python. They are extremely powerful and of industrial strength.

My biggest concern was knowing how portable the code I write would be. It would be ideal to use the code I write in a desktop app or on the web without modification.
Careful, even if the code is technically portable, that doesn’t mean you would run it on the web directly. Aside from the more stringent security checks, you have to be aware that you are under the constraints of a web system. Your program can be called frequently, concurrently, etc. It needs to respond quickly to the user, and so on. None of these requirements are Python specific. They are just generic development guidelines for the web.
Dec 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi | last post by:
Hi, I am considering embarking on a project with mod_python. However I am wondering if the mod_python interpreter is embedded or actually calls the python executable. The documentation says the...
0
by: Jeff | last post by:
Ok, so I'm working on a project right now that is being done in psp through apache. This is working fine, except that in every one of my modules I had to use the mod_python function of...
1
by: skip | last post by:
I'm just getting started with Myghty and using it under mod_python (also a new beast for me). Do I have to worry about threading conflicts between different mod_python interpreters or are they all...
9
by: cyberco | last post by:
And I thought this would be trivial...getting mod_python to run within apache on windows XP. ============= mod_python 3.2.8 apache 2.0.55 python2.4 winxp =============
5
by: dan84 | last post by:
I don't understand this error , in the (Apache) errorlog I read this message : make_obcallback: could not import mod_python.apache.\n make_obcallback: Python path being used "". ...
1
by: boney | last post by:
hello All, I am totally unknown to python language.. i need to install mod_python to embed python interpreter with the Apache server, in order to use Trac with Apache Web Server i am using...
5
by: m.banaouas | last post by:
Hi, bonjour, witch versions are suitable to use for apache & mod_python ? Can i install and use "Apache 2.2.3" & "mod_python 3.2.10" (most recent versions) without facing any known major...
1
by: NccWarp9 | last post by:
Hello, im using Apache HTTPD 2.2.8 with mod_python/3.3.1 Python/2.4.3 on Windows and having truble starting pythone, any help would be appreciated .. Im getting this error: ...
3
by: Lawrence D'Oliveiro | last post by:
In message <mailman.109.1216158151.922.python-list@python.org>, Cyril Bazin wrote: What's the error message? This should be in Apache's error_log file.
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.