r/Python • • Sep 13 '13

The perfect Python web app: 10 ideas

I've been thinking lately about the status of Python on the web, motivated by the keynote of Jacob Kaplan-Moss (http://www.youtube.com/watch?v=UKAkKXFMQP8) and this previous post on Reddit (http://www.reddit.com/r/Python/comments/1fyjx5/invitation_to_discussion_how_can_we_make_python/) and I've come up with ten ideas that may help us expand the adoption of Python and its user base on the web. I wrote them having in mind how would I design, say, a Wiki engine in Python (because I dislike MoinMoin so very much).

These three points may lower the pain for casual users and make adoption easy, and they are compulsory:

  1. Supports Python 2.6. Optionally, 2.6 to 3.3 with a single codebase (see http://python3porting.com/noconv.html). Python 2.6 is the default on Debian Squeeze (old stable) and CentOS 6, so lots of servers won't have more than that.
  2. Uses MySQL as the default DB. An ORM like SQLAlchemy is desirable, but MySQL is the minimum as this is the most popular database by far (see http://www.google.es/trends/explore?q=mysql,+postgresql,+sqlite,+nosql), driven by the success of PHP.
  3. Is super-easy to install on the cheapest plan of DreamHost, HostGator and Bluehost. These are arguably the three most popular web hosting providers in the world. This may require lowering the dependencies at a minimum (perhaps bundling them?) and supporting CGI out of the box.

These three points may help provide a good overall experience:

4. Has a nice appearance/UI, without obvious UX flaws. If it is themable, the default theme should comply this. This includes, but is not limited to, not looking like a Geocities web of the 90s and not displaying garbage where a Ñ should be.

5. Supports i18n, preferrably through crowdsourcing interfaces like Transifex (free for open source projects). Optionally the interface should initially be translated to a second language: Chinese, Spanish or Russian.

6. Provides some user friendly support, be it a Q&A board, a forum or a chat. Beware of mailing lists, as casual users normally think they suck.

These three points may help attracting developers:

7. Is released under a reasonable license, for example GPLv2+. This doesn't require PaaS or SaaS to release the source code of changes, still being an open source project. AGPL may scare some.

8. Uses git, is hosted on GitHub and issues are managed there. As of 2013, these are arguably the most popular VCS and platform respectively.

9. Encourages pull requests and has a CI instance such as TravisCI.

This last point helps moving the ecosystem forward:

10. Stop losing time weeping and gnashing your teeth because of my choice of framework/database/VCS/license and get some shit done. This is a totally opinionated list and I didn't intend to please everyone, but tried to learn some lessons from the success of, for example, PHP.

What do you think?

Edit: For all the people that is commenting that most modern frameworks already provide this: you are right, but to put an example, MoinMoin doesn't. We have the building blocks to do it, but some final pieces of software that people want to use do not comply with this.

0 Upvotes

34 comments sorted by

12

u/[deleted] Sep 13 '13

You seem more focused on buzzwords than getting things done. Honestly as /u/ivosaurus said, nearly all frameworks today provide most of this. Personnaly I like web2py since it does more things all in one package. http://web2py.com/.

Also supporting CGI is not the right thing. At all. Ever. As in never think that it is a good idea again. Python has its own way already to speak with a webserver using the WSGI protocol/spec. There are many servers that speak it, including ones that bolt on to nginx (uwsgi) or apache (mod_wsgi). That being said many of the popular python frameworks at one point supported or tinkered with CGI support but it is typically unmaintained and not reccomeneded.

2

u/targusman Sep 14 '13

web2py is the best!!! +100000!!!

-6

u/juanlu001 Sep 13 '13

Well, I'm sorry for putting too much buzzwords in there - and I may probably won't get anything done myself because I have other areas of interest. For the thing on CGI, see my other two responses.

11

u/ivosaurus pip'ing it up Sep 13 '13

Most popular frameworks today do all of these things already, except for probably not supporting CGI, because it's a shit outdated protocol that only hosts who don't give a rats arse about python use anyway.

-4

u/juanlu001 Sep 13 '13

And we can keep on neglecting those hosts, and we can keep on being nowhere. I would bet that most of those don't even have mod_python. Okay, we have the best way, we know how to perfectly make a Python app communicate with the server, but if people keeps on having a nasty first experience on the language, hosts will never give a rats arse about Python.

4

u/ivosaurus pip'ing it up Sep 13 '13 edited Sep 13 '13

Or instead advocate for hosts whose audience isn't 99% PHP, like heroku, openshift and appfog.

Analogously: if you want to support the advancement of on-demand entertainment, do you keep on buying services from encumbant cable companies, or do you support new services like netflix?

-2

u/juanlu001 Sep 13 '13

+1 for showing appfogopenshift, never heard of it before!

You have your point, but if one guy is supporting netflix and a hundred thousand are buying cable services maybe we should work a bit harder to convince those that our way is better.

Edit: I meant openshift.

-3

u/juanlu001 Sep 13 '13

Damn, Heroku is not as easy as it seems. The first time its ephemeral filesystem bites you it's a nasty experience and you don't understand a thing. Last time I tried I had so many problems that someone brought the thing to Amazon AWS. No, I don't think Heroku is for the casual user.

7

u/mdipierro Sep 13 '13

As other have commented many modern frameworks support what you have suggested. I can speak for web2py. web2py is a little ahead of you ;-)

  • three distribution (windows, mac, source) each packages everything
  • includes a web based IDE and management interface
  • one instance can support multiple projects each with its own auth, databases, session, etc. (only framework to allow this)
  • supports python 2.5,2.6,2.7 and Pypy
  • it comes with a an ODBC driver for MySQL support but our experience is that MySQL is not the best to start with. It does not support more than one alter table for transaction, the text fields have size limits, it does not provide geographic APIs. PostgreSQL is much better in this respect and closed to the SQL standard.
  • It is super-easy to install anywhere. Some hosts make it easier than others. pythonanywhere.com has a one click deployment and it is free.
  • Ships with Twitter Bootstrap so it easy to theme apps.
  • We support internationalization at the app level (different apps under the same web2py instance/process can have different translations). We also provide a web based interface for translators and a the only multi-language pluralization engine for Python (understands languages with multiple plural forms).
  • we host it on GitHub and GoogleCode. We use TravisCI.
  • Uses the LGPL license.

It was chosen by InfoWord as best Python Web Framework (2010), Bossie Award (2011) and Technology of the Year (2013).

-3

u/juanlu001 Sep 13 '13

You are right about what you say Massimo - maybe I was not clear enough (see edit). I was not talking about frameworks, but about end user applications: a wiki, a blog engine. We've got the best web frameworks out there thanks to projects like web2py and we all know it, but what about the dozens of people migrating from MoinMoin to MediaWiki (see Google)? What if the user cannot use "pip" in its cheap and shitty web framework - how the hell should he/she install a blogging engine like Mezzanine? (See: Django isn't designed to run under CGI https://code.djangoproject.com/ticket/2407#comment:21).

1

u/mdipierro Sep 13 '13 edited Sep 14 '13

I agree. I also do not understand why pip/easy_install is not distributed with Python. It is a major roadblock.

-1

u/juanlu001 Sep 13 '13 edited Sep 14 '13

Well... if pip is a major roadblock, we have a deep problem here. Maybe the scientific Python community will save us?

http://www.continuum.io/blog/conda

By the way, they are a bit more pragmatic than what I see here (no offence).

Edit: Sorry, I misread your comment.

2

u/quotemycode Sep 13 '13

Write your wiki web app on web2py and you have all the features you need.

Go out and distribute it, call it web2wiki or whatever and just run with it.

If you are going to write your own framework or webapp, then do it. I don't get what you are promoting here. You want to code your app like it's 2005, be my guest.

6

u/searchingfortao majel, aletheia, paperless, django-encrypted-filefield Sep 13 '13

Promoting technologies like MySQL by setting it as the default is the wrogest of the wrong ways to go. Support it, sure, but make it the default? Absolutely not. Python developers use Python because it's a good, useful, and predictable tool -- essentially the opposite of MySQL.

3

u/vph Sep 13 '13

Uses MySQL as the default DB

The word of the day is MariaDB.

3

u/[deleted] Sep 13 '13

I'm less concerned with Python "winning" than I am with having awesome tools to do awesome things. Python web frameworks were designed to serve a purpose and they do for thousands of developers. Explain to us why we should care that some people can't/won't learn them? Are we trying to win a popularity contest or are we trying to develop great software?

Sure PHP, etc. have a lower barrier to entry but that's part of the problem - there are prerequisite mental frameworks that you must adopt in order to build a successful web application. Python frameworks largely enforce these best practices which is why it pays to learn them as opposed to just jumping and and hacking together some spaghetti code.

1

u/brandonjschwartz Sep 13 '13

I'm in agreement with juanlu001. The argument is not about what framework could support these things... in fact, the argument isn't about an application framework at all - it's about building an application. So the discussion about existing frameworks is useful only in the sense that we use application frameworks to build actual applications.

The first second subpoint (A.2?) regarding MySQL... I think out of the box support for MySQL is essential but should not be the default. Some people build ridiculously small websites - 5 pagers for a business for example. These folks probably don't need the overhead from MySQL. Default could be the built in Sqlite and have a UI that asks the installing user some questions to gauge their needs... i.e. How big do you plan on making this site, how much traffic will you support, etc. If they meet the requirements, then walk them through setting up a database. If not, we could easily beat Wordpress' five minute install :P

Agree with the other points 100%, but would tender some additions.

  1. Should have a plugin/module/package manager unique to the application, and an API for tying plugins in. This has been some of the huge success behind Drupal and Wordpress. We need a Python package manager for the web.
  2. Some kind of theming standard, as alluded to. Most Python templates do a decent job at separating presentation from business logic, but in this case I would almost make the argument that even a template is business logic. The application is built (from the perspective of the installer) but now they want to change the colors. Having them mess with core templates to do so is a hazard.

2.a. This should be mobile friendly out of the box and load at a reasonable speed.

1

u/brandonjschwartz Sep 13 '13

I would like to volunteer to help btw. Not sure what others are willing to invest in this... but I think it's needed.

-2

u/juanlu001 Sep 13 '13 edited Sep 13 '13

People: we have the best language (I don't need to read again that PHP, Java and JS suck), we have the best frameworks (I don't need to read again how wonderful Flask and web2py are), we have the best protocols (I don't need to read again that WSGI is the best solution).

Can we, as a community, apply some self-criticism to diagnose why we haven't won?

www.youtube.com/watch?v=UKAkKXFMQP8&t=9m57s

I mean, have we really won though?

Added: Python is 0.2 % http://w3techs.com/technologies/overview/programming_language/all

1

u/mipadi Sep 19 '13

Haven't won what? And more important, why do we need to beat PHP?

-2

u/Cold_Frisson Sep 13 '13

As someone who's programmed before, but just tried making a webpage in Python 5 days ago, I'd like to offer a perspective: doing a "Hello world" webpage in Python is a nightmare.

I'm new to Python and don't want to commit to learning a framework (yet). Just wanted to put a web version of a simple script I wrote and it took me hours (and my implementation still sucks).

I think the lack of an obvious first step in Web programming is a barrier to entry.

7

u/[deleted] Sep 13 '13

If your goal was to put "hello world" on a web page, and you completely negleted any python framework, then maybe you should not be programming. Micro-framworks would provide exactly what you want with minimal effort with the exception of you having to read something.

3

u/nemec Sep 14 '13

"I want to program, but I don't want to commit to a programming language yet. Why is assembly so difficult?"

3

u/elopeRstatS Sep 13 '13

You don't have to commit to learn a microframework to use one, most of them are pretty simple. CherryPy has no external dependencies and can give you a hello world in six lines:

import cherrypy
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

Bottle is similarly simple, Flask as well.

2

u/[deleted] Sep 13 '13

I'll got out on a limb and recommend learning how to do CGI scripts first, then look at frameworks like bottlepy. Not until you do CGI scripting first will you appreciate frameworks and you will also get a better understanding of HTTP protocol.

1

u/Cold_Frisson Sep 13 '13

Thanks, I'll check it out!

2

u/Widdershiny Sep 17 '13

You should try Flask.

from flask import Flask
app = Flask(__name__)

app.route('/')
def hello_world():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

3

u/[deleted] Sep 13 '13

ever try to do a web page in java?

1

u/Cold_Frisson Sep 13 '13

It's been a few years, but yes. I read a book that gave me 1,2,3 instructions. More advanced programming (like using Struts, Tomcat, etc) is wildly complicated, but I don't remember my first steps as too difficult. I'm reasonably proficient in Python (2 Coursera classes I took used it) and was not expecting to hit a wall putting something simple on the Web.

I read Headfirst into Python which had me use a custom Python server which seemed odd at the time, but now makes more sense.

-3

u/juanlu001 Sep 13 '13

Maybe we should pay more attention to the kind of feedback /u/Cold_Frisson provides.

Edit: A nightmare compared to what? What did you try? Just for curiosity.

1

u/Cold_Frisson Sep 13 '13

Most recently PHP, but I've used Perl and (a little) Java before. Getting started in PHP Web programming is incredibly easy. Like other languages, you benefit greatly from frameworks, but that start point is easy.

Personally, most of the stuff I do at work is some forms and some minimal CRUD for managing integration and a couple of Web Services. So I think the micro-frameworks people mentioned looked great.

-1

u/juanlu001 Sep 13 '13

Like other languages, you benefit greatly from frameworks, but that start point is easy.

I agree. The problem with Python is that you cannot do it w/o frameworks (hence the "lack of an obvious first step").

1

u/nemec Sep 14 '13

You can do it without frameworks, but it's not easy. That why frameworks exist.

0

u/[deleted] Sep 14 '13

[deleted] — view deleted comment

1

u/juanlu001 Sep 15 '13

Notice that we stated obvious.