Topic: django/python as web framework

Hi,
just wondered if anybody here is using anything Python based for their project websites. I've noticed that there is Python 2.4 and 2.5 installed and I was told that Python scripts are supported through CGI, but my tries at deploying virtualenv, a userspace python library manager, failed. Thus i'm curios if anybody else ever tried to run MoinMoin, CherryPy, Plone or anything else Python powered.

Cheers
Neme

Re: django/python as web framework

MoinMoin should works, there is an example about using it with CGI in their website.

Plone works only with Zope which is an application server, which should be used for example instead of the Apache HTTP server.

CherryPy is also an application server.

Sylvain

Re: django/python as web framework

Thanks for the reply :)

Well, to be precise both Zope and CherryPy can be used with Apache, but nevermind.

Running serious systems with python requires a better interface than CGI anyway. Pure CGI is not supported by most projects, highly discouraged or not seldomly seen as "the last possible solution". CGI installations are most often hacky and extremely slow / resource intensive.

I must admit that supporting Python on a web server is something you don't see very often, even more seldomly along free hosting services. That might be because Python's web usage doesn't look back at such long history as PHP or Perl, but apart from that it has proven it's possibilities in many situations. There are many known web apps written in Python, such as MoinMoin or Trac to call the most famous. Beside that very specific apps Python is known for its web frameworks. Django, TurboGears, Zope - there's nothing comparable in the PHP world; or at least I don't know of any ^^. With such frameworks it's as easy as assembling ~100 LOC to write your custom CMS, wiki, blog, gallery and whatnot.

Sorry, carried away…
What I'm saying in general is: a usable Python environment on Tuxfamily would be a great new feature and many developers would profit from that. And the price for it all is as little as enabling (serious) Python support on the server. Before going into detail, I guess it's better to link you here: http://docs.python.org/howto/webservers.html That page explains incisively pretty much everything there is to know about Python in conjunction with Web.

I can't call myself a Python professional, since I'm coding it for only about 1,5 years now, but I'd be happy to help if you have a need for me.

Have a nice day,
Neme

Re: django/python as web framework

Hi,

nemesis13 wrote:

Well, to be precise both Zope and CherryPy can be used with Apache, but nevermind.

Of course, everything can be used with or behind Apache.


nemesis13 wrote:

Running serious systems with python requires a better interface than CGI anyway. Pure CGI is not supported by most projects, highly discouraged or not seldomly seen as "the last possible solution". CGI installations are most often hacky and extremely slow / resource intensive.

I must admit that supporting Python on a web server is something you don't see very often, even more seldomly along free hosting services. That might be because Python's web usage doesn't look back at such long history as PHP or Perl, but apart from that it has proven it's possibilities in many situations. There are many known web apps written in Python, such as MoinMoin or Trac to call the most famous. Beside that very specific apps Python is known for its web frameworks. Django, TurboGears, Zope - there's nothing comparable in the PHP world; or at least I don't know of any ^^. With such frameworks it's as easy as assembling ~100 LOC to write your custom CMS, wiki, blog, gallery and whatnot.

Sorry, carried away…
What I'm saying in general is: a usable Python environment on Tuxfamily would be a great new feature and many developers would profit from that. And the price for it all is as little as enabling (serious) Python support on the server. Before going into detail, I guess it's better to link you here: http://docs.python.org/howto/webservers.html That page explains incisively pretty much everything there is to know about Python in conjunction with Web.

I can't call myself a Python professional, since I'm coding it for only about 1,5 years now, but I'd be happy to help if you have a need for me.

Everything that need to change the Apache configuration is not easy at all. That would require a whole integration into VHFFS and a way to reload not one, but a cluster of webservers, and so, without causing any service disruption due to badly generated configuration.

Next, everything other than CGI require persistent processes for performance... per project... this is not scalable at all, and would require a lot of memory.

We also have some constraints due to shared hosting that must need to be taken into consideration. Each user and group have its own, respectively, UID and GID, each process must be running with the right owner and group. Each user/group can only access on the filesytem their files for security reason, it's needed for localpart set on local mails sent, it's also needed to set limits on resources on kernel side which are of course per UID/GID, for disk quota usage, and so on.

Perl has exactly the same problem Python has with CGI, ruby either ;-)

PHP, on the other side, spawn quickly, compile and run the code quickly, so it works perfectly fine with CGI, is easy to fork with the right UID/GID, run on a cluster of webservers seamlessly, it don't need any modification over time on the Apache configuration, so Apache servers don't need to be reloaded, it also don't need proxying, nor persistant processes, nor virtual machines. This is mainly why PHP is always available and others not.

We are not against about offering python through other means that CGI, but this is not something that could be done in an evening, this is a complete rewrite of how TuxFamily works for now over ten years, that would require several months of continuous work, new hardware with much much more memory, and more time needed on the day-to-day administration. For my part, I don't really see how make something which is more stable than a house of cards.

Sylvain

Re: django/python as web framework

Some good points you have there. I didn't know CGI is that leightweight on resources.

Have a nice day
Neme

Re: django/python as web framework

Hi,

nemesis13 wrote:

Some good points you have there. I didn't know CGI is that leightweight on resources.

CGI on itself is very light, this is a very simple interface to spawn interpreters.

The problem is that Perl, Python, Ruby are so slow that they need to be pre-spawned, and often pre-feed with the code so that it can be compiled in advance, so that everything is ready to execute on request.

This is what all application servers do, Tomcat, Zope, CherryPy.

The main problem is that pre-spawning and pre-feeding process for thousands of users is a pure nightmare to do.

Sylvain

Re: django/python as web framework

I would like to install django on tuxfamily webhosting
please help!
http://fmtyewtk.blogspot.com/2010/05/dj … n-web.html

what should i send the PYTHONPATH to? where can i put the python data?

Re: django/python as web framework

Hi,

To summarize the explanation done on IRC.

h4ck3rm1k3 wrote:

I would like to install django on tuxfamily webhosting
please help!
http://fmtyewtk.blogspot.com/2010/05/dj … n-web.html

what should i send the PYTHONPATH to?

Python are installed using Debian packages, you probably don't need to worry about that.


h4ck3rm1k3 wrote:

where can i put the python data?

In the php-include directory, which is misnamed and doesn't include anything, but is out of the htdocs and so out of the http scope.


Sylvain

Re: django/python as web framework

http://osmtask.tuxfamily.org/django/runtest.py

this is a simple python script that prints the output, but it is not working.
cat runtest.py

#!/usr/bin/python

import sys
import os

for param in os.environ.keys():
    print "%20s %s" % (param,os.environ[param])

please help

Re: django/python as web framework

Hi,

h4ck3rm1k3 wrote:

http://osmtask.tuxfamily.org/django/runtest.py

this is a simple python script that prints the output, but it is not working.
cat runtest.py

#!/usr/bin/python

import sys
import os

for param in os.environ.keys():
    print "%20s %s" % (param,os.environ[param])

please help

You seem to be unfamiliar on how HTTP works, I fixed your script by adding the necessary HTTP headers. I also chmoded +x it, this script needs to be an executable because this is the way it is ;-).

Sylvain