choice of web-framework

Chris Angelico rosuav at gmail.com
Sun Oct 22 06:41:17 EDT 2017


On Sun, Oct 22, 2017 at 9:24 PM, Patrick Vrijlandt <nieuws.pv at xs4all.nl> wrote:
> Hello list,
>
> I would like your recommendation on the choice of a web framework.
>
> The project is completely new, there are no histories to take into account
> (current solutions are paper-based). The website involves questionnaires
> that will be developed, filled out and stored. Users are not programmers or
> developers. They should be authenticated. Version control is required.
> Internationalization is not an issue. I expect that the project will add
> additional requirements and complexity later on that I can not foresee yet.
> I'm targeting a single deployment (maybe a second on a development machine).
> I usually work on Windows, but Linux can be considered.
>
> I'm not afraid to learn a (=one) new framework (that would actually be fun)
> but trying out a lot of them is not feasible. My current goal is a
> demonstration version of the project as a proof of concept. I may want to
> hand it over to a commercial solution at that stage.
>
> I'm an experienced python programmer but not an experienced web developer. A
> few years ago I read some books about Zope and Plone, but never did serious
> development with those. I currently maintain an intranet site in MoinMoin. I
> assume Zope could still be a potential choice, but it may have lost the
> vibrancy of a few years ago. Also, I would not know which version to choose
> (Zope 4, BlueBream, or something like Grok). The problem seems too
> complicated for micro frameworks like bottle of Flask. Django could be the
> next alternative.
>
> Finally, for a new project, I would not like to be confined to Python 2.7.
>
> What are your ideas?

First off, a huge thank-you for laying out your requirements in such detail!

My personal choice, under the circumstances, would be Flask. Your
project isn't too complicated for it, and it's not too hard to learn
(I learned it in a weekend, though YMMV of course). Authentication is
a fully-supported plugin (flask-login). I'm not sure what you mean by
"version control" - of course your actual Python code can be managed
in git/hg, but if it's a project requirement that your *data* be
git-managed too, then you'll need to plan something out for that. Not
too hard though.

Python 3 is fully supported by Flask, so that's not a problem. Windows
and Linux are also both viable platforms. I strongly recommend
creating a file "requirements.txt" in your project root and recording
every package you use there, so you can just run "pip install -r
requirements.txt" to grab everything. Using a virtual environment
("python3 -m venv env" in recent-enough Pythons) can help to keep your
dependencies clean. If you do that from the start of the project, and
avoid using anything that's Windows-specific, you shouldn't have much
trouble changing OSes.

For the database, I generally use PostgreSQL, unless the job's so
simple it can be done with flat files. Using Flask with SQLAlchemy is
a popular option, but you can also dive into psycopg2 directly (the
"2" doesn't mean "Python 2.7 only", it's fine). The tech stack
Python+Flask+SQLAlchemy+PostgreSQL+Linux is an extremely solid one, or
you can switch out any part fairly easily.

Disclaimer: I use Flask and SQLAlchemy when I'm teaching my students
how to build web apps in Python, but I don't have much experience with
any other frameworks or ORMs. Other options may very well be viable
and/or superior; all I can say is that the above *is* viable.

ChrisA



More information about the Python-list mailing list