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

Home Posts Topics Members FAQ

Trying to understand Python web-development

I don't know much php either, but running a php app seems straight
forward enough.

Python seems to always use some sort of development environment vs
production environment scheme. For development, you are supposed to
run a local browser and load 127.0.0.1:5000 - or something like that.
Then to run the same thing in a development environment, I have to
configure some files, or touch all the files, restart the web-server,
or something. Why is that?

Python also seems to require some sort of "long running processes" I
guess that the python interpretor has to running all of time.

I am not really sure about what wsgi is supposed to accomplish.
Jan 29 '08 #1
5 1626
On Jan 29, 2008 12:11 PM, walterbyrd <wa********@iname.comwrote:
I am not really sure about what wsgi is supposed to accomplish.
This will explain WSGI: http://www.python.org/dev/peps/pep-0333/
Jan 29 '08 #2
walterbyrd a écrit :
I don't know much php either, but running a php app seems straight
forward enough.
Mmm... As long as the whole system is already installed and connfigured,
*and* matches your app's expectations, kind of, yes.
Python seems to always use some sort of development environment vs
production environment scheme.
s/Python/some frameworks/
For development, you are supposed to
run a local browser and load 127.0.0.1:5000 - or something like that.
Then to run the same thing in a development environment,
I suppose you meant "in a production environment" ?
I have to
configure some files, or touch all the files, restart the web-server,
or something. Why is that?
Developping directly on a production server is defiinitively a no-no,
whatever the language. So you *always* develop un a development
environment. In PHP, this imply having a running HTTP server - usually
Apache - correctly configured. Some Python frameworks, OTHO, ship with
their own lightweight Python-based http server, which usually makes
things far easier. Since quite a lot of web programmers already have
Apache running on port 80, the framework's own server usually runs (by
default) on another port. Also, most of the time, on the production
server, you choose some other more appropriate deployement solution -
which may or not include Apache - depending on the context. So the nice
point here is that:
1/ you have way more freedom wrt/ possible deployment solutions
2/ you don't have to replicate the whole damn thing (if ever possible)
on your local machine to develop the app.

Of course, the actions to be taken when updating your app on the
production server greatly depends on the deployment solution.
Python also seems to require some sort of "long running processes" I
guess that the python interpretor has to running all of time.
s/Python/some frameworks/

You can write web apps in Python using plain cgi, you know. It's just
very inefficient due to how cgi works - to make a long story short: the
system has to launch a new process for each request calling your script,
and you have to rebuild the whole damn world each time your script is
called. Note that PHP suffers at least from the second problem, which
can make it somewhat inefficient for some kind of applications.

The point of long running processes is that most of the world is only
built at startup and stays here between requests.
I am not really sure about what wsgi is supposed to accomplish.
First and mainly, allow Python-based web apps to be independant from the
deployment solution, by adding an indirection level. Instead of having

[yourapp]<-->[http_server]

which only work for the http server you targeted, you have

[yourapp]<-->[wsgi]<-->[http_server.wsgi_adapter]<-->[http_server]

which works for any http server for which a specific wsg adapter exists.

There are also some other benefits since, the way wsgi works, the [wsgi]
part of the above schema can include quite a lot of other things,
sometimes without your application being aware of it (you may want to
look for 'wsgi middleware' for more on this).
HTH
Jan 29 '08 #3
walterbyrd wrote:
Python also seems to require some sort of "long running processes" I
guess that the python interpretor has to running all of time.
What you probably don't realize, is that in 99.9% of the situations you've
come across, PHP is already a process running all the time. It's called
mod_php, and it's a PHP interpreter running inside of apache, thus a "long
running process." It's just not as obvious. You can do the same thing
with Python via the mod_python module, thus putting the python interpreter
(instead of the PHP interpreter) inside the Apache process. Other web
servers have similar setups. Google for FastCGI and SCGI.

j

Jan 29 '08 #4
On 29 Jan, 18:11, walterbyrd <walterb...@iname.comwrote:
I don't know much php either, but running a php app seems straight
forward enough.
I think that this (the ease of PHP application deployment) is one of
the things that keeps Python framework developers up at night,
regardless of whether the cause is technical (what processes or
components are running) or social (that hosting providers install
enough of the useful PHP stuff for people not to care about wanting to
install more).
Python seems to always use some sort of development environment vs
production environment scheme. For development, you are supposed to
run a local browser and load 127.0.0.1:5000 - or something like that.
Then to run the same thing in a development environment, I have to
configure some files, or touch all the files, restart the web-server,
or something. Why is that?
You can deploy Python Web applications using anything as simple as CGI
(which only requires a single change to the Web server setup), right
up to the full application server configuration. For a long time I've
advocated the ability to be able to do this without having to switch
frameworks and rewrite your code: that's what my WebStack package [1]
is all about, and I guess that given the availability of the right
adaptors and framework support, WSGI should let you do this as well.
Python also seems to require some sort of "long running processes" I
guess that the python interpretor has to running all of time.
Not so: deploying anything as a CGI script/program means that the
application code is only run when a request is made to the
application. Lots of Python software can use this approach: MoinMoin,
ViewVC, Trac... (All these things have, notably, implemented their own
mechanisms for abstracting away the deployment technology, since they
also work with things like mod_python. Another sad example of the
community not coalescing around standards, although I think they're
all looking into WSGI now.)
I am not really sure about what wsgi is supposed to accomplish.
It's supposed to decouple the deployment technologies from the
framework technologies, or at least that's what I'd use it for, and if
all frameworks supported it, you'd supposedly be able to take, say,
your Django application and run it on Zope 3, or your TurboGears
application and run it on Twisted. Of course, you'd write your Django
code differently from any Zope 3 code in your application, and the
TurboGears code wouldn't look a lot like Twisted code, but that's
another issue entirely.

Paul

[1] http://www.python.org/pypi/WebStack
Jan 30 '08 #5
Thanks for all that posts. This thread has been helpful.

I have seen a lot of posts about the importance of decoupling the
deployment technologies from the framework technologies. This is how I
have done that in PHP. I develop on my home box. When I get something
working the way I want, I ftp those files to the remote server. To me,
that seems to make more sense that trying to run two different web
servers on the same system. My PHP system involves no monkeying with
special config files, or running special servers to couple the
different environments, or setting special ports, or paths. For PHP
development, I don't even need ssh access.
I think that this (the ease of PHP application deployment) is one of
the things that keeps Python framework developers up at night

I think you may have something there. For $10 a year I can get an
account at dollar-hosting.net, copy some php files there, and that's
all there to it. I have been beating my brains out trying to get
anything working with a python framework, and I have not been able to
do it. I even bought VPS hosting just for the sake of python
development. But, I still can not seem to make the quantum leap of
getting something that works locally, to work remotely. BTW: with the
VPS hosting, I had to install and configure my own web-hosting and
PHP, including setting up lighttpd with fastcgi and php modules - and
I still found that much easier than getting anything to work with
python.
Jan 30 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: ckb2102 | last post by:
Hi there, I am new to this so I apologize in advance if I am not following the right etiquette or something... I am working on a project for school. My partner has written a short program in...
3
by: Steven D'Aprano | last post by:
I've been doing a lot of reading about static methods in Python, and I'm not exactly sure what they are useful for or why they were introduced. Here is a typical description of them, this one...
5
by: Mike Krell | last post by:
I'm running into problems trying to override __str__ on the path class from Jason Orendorff's path module (http://www.jorendorff.com/articles/python/path/src/path.py). My first attempt to do...
20
by: walterbyrd | last post by:
Reading "Think Like a Computer Scientist" I am not sure I understand the way it describes the way objects work with Python. 1) Can attributes can added just anywhere? I create an object called...
34
by: Anthony Irwin | last post by:
Hi All, I am currently trying to decide between using python or java and have a few quick questions about python that you may be able to help with. #1 Does python have something like javas...
5
by: Alan Silver | last post by:
Hello, Server configuration: Windows 2003 Server SP2 SQL Server 2000 SP4 ..NET v2.0.50727 just built up a new server using the same configuration as my current one. I even used the same CDs...
2
by: Carnell, James E | last post by:
I am thinking about purchasing a book, but wanted to make sure I could get through the code that implements what the book is about (Artificial Intelligence a Modern Approach). Anyway, I'm not a...
4
by: spectrumdt | last post by:
Hello. I am trying to extend Python with some C code. I made a trivial "Hello World" program in C that I am trying to wrap in "boilerplate" for inclusion in a Python program. But I can't compile...
12
by: thegman | last post by:
Hi all, I'm trying to get list of JavaScript methods/functions in a script file in much the same a good text editor will, the difference being that I need to output it to a file or stdout, or some...
5
by: tedpottel | last post by:
Hi, My program reads as follows import urllib print "-------- Google Web Page --------" print urllib.urlopen('http://www.google.com//').read() print "-------- Google Search Web Page...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
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?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.