473,903 Members | 5,147 Online
Bytes | Software Development & Data Engineering Community
+ 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 1645
On Jan 29, 2008 12:11 PM, walterbyrd <wa********@ina me.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.wsg i_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...@ina me.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
1880
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 Python which takes 2 arguments - the name of a .mov file and a number which represents the number of seconds into that movie. The program then passes this info to MPlayer and produces as output a .jpg image which is basically the frame of the...
3
2002
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 from Guido: "The new descriptor API makes it possible to add static methods and class methods. Static methods are easy to describe: they behave pretty much like static methods in C++ or Java." http://www.python.org/2.2.3/descrintro.html
5
2478
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 this was as follows: ''' class NormPath(path): def __str__(self): return 'overridden __str__: ' + path.__str__(self.normpath())
20
1921
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 point, then I can add attributes any time, and at any place in the program? 2) Are classes typically created like this: class Point:
34
3726
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 .jar packages. A jar file contains all the program files and you can execute the program with java -jar program.jar I am sort of hoping python has something like this because I feel it
5
2554
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 and registration keys, so I'm certain that the two machines are as similar as they can be.
2
1944
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 very good programmer and OOP is still sinking in, so please don't answer my questions like I really know anything. MY QUESTION: What is a slot? In class Object below the __init__ has a slot. Note: The slot makes use of a data object called...
4
5442
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 the C code. The C compiler cannot find the required function `Py_BuildValue'. My C code looks like this:
12
10911
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 other way of "getting at it" automatically. I'm not fussy about what language I use, be it JavaScript or something else. Anyone got any ideas? I've tried Exuberant Ctags, but that does not seem to work on very advanced scripts like Ext. I'm...
5
2003
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
9999
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11282
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9684
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8048
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7206
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5894
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4726
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 we have to send another system
3
3324
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.