PyCon 2014

Las partes buenas de Django

James Bennett  · 

Presentación

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

all right the last speaker in this session is James Bennett he's gonna be talking about the good parts of Django hi okay so I know you're all anxious to get to lunch fortunately there aren't that many good things in Django so this won't take

very long just by way of introduction my name is James Bennett I'm one of the release managers for Django used to work at the Lawrence Journal world which is the company in Django originally came out of I've been involved with Django for quite some

time not as long as Django has existed though the initial public preview of it which I remembered downloading and playing with and falling in love with was in July 2005 so we're looking at you know about nine years of Django releases growing adding code

adding features what does Django look like today well we just did the 1.7 beta 160 1923 lines of Python was the count that I got out of that Django is now you know we call it a full stack framework because we have well a full stack of all of these things request

in response and templating and ORM and forms and authentication and it just keeps going and going and going there this huge list of features Django can now be literally described as the 800-pound gorilla of the Python web framework world a title that I believe

we've claimed from zope by throwing enough bananas at them to blow up the building they were on so this raises a question aren't other frameworks smaller or lighter or better or more flexible than Django what is it that Django still has still does

that makes it a good choice so I want to talk about three things mainly the good parts of Django first one I want to talk about is gonna be the HTTP abstractions that Django provides and the way Django handles HTTP and your request response cycle second is

the conservative and yes I do mean that word conservative approach to adding features third and finally our secret weapon you know amongst our weapons are surprised fear a fanatical devotion to the Pope and the Django application which is something we will

talk about in a few minutes but first let's talk about HTTP HTTP sucks when no love for that okay HTTP has some problems has nine different request methods god only knows how you keep track of all of them and what options go with them it is completely

and hilariously unaware that Unicode exists persistence and off and streaming and security and all these other things that we care about here in 2014 were kind of either never added or tacked on was like oh maybe we should do that ten years later the HCV really

kind of sucks as a protocol to work with and traditionally if you wanted to write programs that spoke HTTP you wrote CGI CGI is also not a lot of fun here's in theory in theory if you were to read a CGI tutorial this is what it would tell you would tell

you that you're going to write a script the web server is going to set up all of the request information in environment variables and then invoke your script your script is also going to receive any submitted data from the request over its standard input

your script will then read the environment to figure out what's going on read the standard input to figure out what's going on do its processing and then on standard output send out your response headers and your response body who here believes that

this is how CGI actually works in the real world I noticed not a lot of hands that's a good thing here's how CGI actually works first of all you hope and pray that the web server will actually invoke your script it may or may not at some point you're

going to type a command that looks like this you're not going to understand why and if you don't get why you're doing that ask someone who has a very very large beard to explain what that means the environment that you're going to be handed

by your web server is full of lies and sadness and things that are going to make you upset at some point you're finally just going to give up on trying to figure out what URL was requested because that information could be in any of multiple different

environment variables and you're just going to try to fork bomb the server after which you will finally completely give up and start drinking this is how real programmers really do CGI I have done this for a living now fortunately in Python we don't

have to write CGI we write whiskey unfortunately whiskey is basically CGI done in Python I realize you know some people may not like hearing whiskey criticised having a standard is important whiskey is our standard gateway interface but number one it is a

CGI style programming model you're handed and environment you are expected to parse and understand what is in that environment rather than be hand handed any kind of normalized data which means that your entire whiskey stack has to parse that environment

okay now we passed it to this component which has to reparse it which passed it to that component which has to reparse it and you just end up with this mess of parsing an environment there really was never that good of a programming model begin with second

[ ... ]

Nota: se han omitido las otras 2.548 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.