Framework for a beginner

lkcl luke.leighton at gmail.com
Thu Apr 19 00:21:10 EDT 2012


On Apr 11, 9:11 pm, biofob... at gmail.com wrote:

> I am new to python and only have read the Byte of Python ebook, but want to move to the web. I am tired of being a CMS tweaker and after I tried python, ruby and php, the python language makes more sense (if that makes any "sense" for the real programmers).

 yeah, it does :)  python is... the best word i can describe it is:
it's beautiful.  it has an elegance of expression that is only marred
by the rather silly mistake of not taking map, filter and reduce into
the list object itself: l.map(str) for example would be intuitive,
compact and elegant.  instead, i have to look up how to use map each
and every damn time!  the reason for the mistake is historical: map,
filter and reduce were contributed by a lisp programmer.  that lisp
programmer, presumably, was used to everything being function(args...)
and it simply didn't occur to anyone to properly integrate map, filter
and reduce properly into the list objects that they work with.

 *shrugs* :)  but that's literally the only thing about python that i
could possibly complain about.  everything else, it's just...
beautiful.  i think also that as a general rule, python programmers
are just... more intelligent.  either it does something to their
brains, or... yeah :)


> I heard a lot of good things about Django, Pyramid, etc, but I dont want to pick the most used or the one with the most magic. Instead I was thinking about one that could "teach" me python along the way. My plan is to rebuild my portfolio using python and a framework and also benefit my python learning along the way.

 as you've seen quite a few people respond already by now, i won't
extol the virtues of different web frameworks, but one thing that's
very hard to assess is what you need.  what exactly do you intend to
do?

 let me give you an example.  i started doing web programming with
python, back in 2001.  the only available big web framework was zope,
and it was far too cumbersome.  so i wrote my own sql table-generator
(called pysqldb - you can still find it on sourceforge), and i wrote
my own HTML table and form generator.  i used cgi-bin.  that was good
enough.

 then i discovered ian bicking's sqlobject and sqlforms, and started
using that, for a bit (it became the basis of turbogears).

 _then_ i discovered django, and went nuts over that.

 and theeeeen, i discovered pyjamas, but i *still* used django for the
back-end, because of the database table capabilities, and *especially*
because of django south (and then django evolution) which, in a large
environment where stability and stable upgradeablity is paramount, you
really _really_ should investigate.

 theeen, because pyjamas basically uses JSONRPC, and you only need to
use HTTP POST for file uploads and HTTP GET for file downloads, i
started looking at alternative _really_ minimalist frameworks, and i
mean severely minimalist.  mod_python (yes really *just* mod_python -
not even a framework!), going back to cgi-bin with a view to doing
fast_cgi in a single process, and even experimented with using yield
and generators but that's getting seeeriously esoteric.  more recently
i've discovered mongrel2, which i love, and will play with more when i
have a chance or the need.

 but for the latest project, i'm not even using SQL: i'm using
something called kirbybase, and i'm using cgi-bin.  there's simply no
need for speed: i don't _want_ to install django when it's not even
needed.  i needed file upload: i just used CGI multi-part forms by
googling for it (there's a recipe on activestate that's about 30 lines
of code demo).  i needed file download: i googled "cgi-bin python file
download" and yet again, another recipe on activestate showed me how:
it's doable in about 20 lines.  i wrote a JSONRPC service - again cgi-
bin based: it's 140 lines of code.  that's enough - it does the job,
and i don't need more!

   http://pyjs.org/pygit/pygit.html?repo=pyjamas.git#file=pyjs/jsonrpc/cgihandler&id=4fb8b7d7902ddbb79507c977eb52f6645f9912ef

so the point is: if you don't need something, and you're never going
to need it, don't use it.  i stuck with django not because of django,
but because the database migration module is just fricking awesome.
but when i didn't even need SQL relational queries, i dropped the
whole of django like a stone.

so - really: you really do need to let us know what kinds of web sites
you intend to write.  are they static (unlikely), is there data
involved, is there file upload/download involved, will there be lots
of data input, will there be automatic file creation involved (PDF
reports from database queries for example), will there be multimedia
(audio, video, live or just pre-recorded) involved, etc. etc.

all of these things have such a massive influence on what's best
practice to use, dude :)

l.



More information about the Python-list mailing list