 Okay. Hi. My name is Alexandre Bourget, I am Director of Development at SavoieFalignix.com or anyway. And I'm going to present you today the web server gateway interface also known as WSGI which is PEP333. So we'll see what is it then what does it look like and we'll have a quick demo. So what's WSGI? Maybe some people remember CGI or fast CGI or something like that. WSGI is like the Java servlet of Python, so a standard way to deploy web application and it's a kind of a web server standard. So first of all, so that's a bit of the flow here, we have an Apache server or IIS or other stuff with a module that supports WSGI which is going to run at startup Python interpreter and run your program which hosts what has your application inside. And it's going to loop and wait, unlike CGI which is going to spawn a new process every request. So we have a little user there that's going to try to get something and it's going to get dropped through Apache in your ASCII query and the module WSGI is going to knock here and call the WSGI application as some Python code. So the app here is going to be an object, it's going to create that environment variable, it's a dictionary similar to a CGI dictionary and then it's going to call wait for the response and set it back to the user which is going to be very happy. So what does it look like? So it has three modes, first of all an application mode, of course that's the simplest application, the hello world. So it's just going to send out the headers with the response here and it's a generator, it accepts two positional arguments in the environment and start response. This one holds all the data like where the path requested are in the query string and the version of the server and stuff like that. So we'll see that right after and of course it should do something. And this returns a generator, so that's an example environment dictionary, you'll have a method here and a file like object to feed everything that was posted like an upload or stuff like that. So I can find the server which is for the example of this one here and is responsible to create that environment and pass it on to the Python application, everything wrapped into a good Python code, of course yield with a response, send it back through sockets and stuff like that. And some sweetness, middleware. So that's the power here that WSGI gives us, it's reusability, we can use standard stuff just like servlets and plug into our application like this. So this here is a middleware because it acts as a server to this application and acts as an application here and it's going to be a bit like a decorator too because it can or cannot, if it will, not call this one, if it can handle for example slash DAV in the web server, which we'll see right after. So it can call it like that, that's why it can act before, after mangling the response or stuff like that. Okay, so for example my application has a stack, that's a stack session handler and we'll have the response, someone calls getting something, first of all goes through error, middleware, just nothing, just pass on the request, session is going to add the session data to environment dictionary. So that's how data get passes through all the layers and my app, oop, going to crash, I have an exception. So it goes through middleware, that's an error, and it goes here, well this one just goes through an error middleware, it goes to create a beautiful error page and then send back the request here, beautifully. And of course, we can also have some real time answer and response and debugging over the web. Okay, so now let's have a little presentation. So for example WSGI DAV, yeah that's alright, WSGI DAV, so you can go and grab it with WSGI, you clone it or just easy install, okay, like you do with anything else. Then I have a sample of Pylons application here, we're going to put that slash DAV and send it to the controller slash DAV, okay. So let me just paste that code here, we're going to save the file and then we're going to take the other part which goes in the controller, here a WDAV controller. So I'll go here, the application is in WSGI app, my app controller, is anyone just going to cat that in there? And notice here how I'm giving a config file to that WSGI app and the slash is going to be mapped to a virtual or on drive file system in that directory here and also have a slash some TMP which is going to point to slash TMP on my drive, okay. So we're just going to enable the virtual environment, whoops. And then we're going to run Pylons, okay so it's running on the port 5000, now let's look at that directory here, what's inside, see we have foobar at PNG and some file, there's a content in there, so we have some random content, yep. Okay, so now that's the application from the web server and what if we launch Nautilus, well we have that slash DAV and we can access the PNG file and modify some content, add some stuff and then, what about, so we have read write through the WSGI app, okay so that's pretty awesome, so you can configure and have that, okay now we're going to make the thing crash, so we're going to create here a controller called demo and exit that file which is, it's been created and we're going to add some crash code here, raise runtime error, blah, stuff like that, okay and we're going to run, whoops, run the server again and let's go back here, we'll have demo index, wow it crashes and look that beautiful WSGI error handler over the web which can interpret any Python code and you can do introspection, what's in the request there, whoops, environment and we can reassign, modify variables in there, so that's pretty much the sweetness middle where it can do for your web framework too because you can plug it in any WSGI, you have a whole bunch of WSGI stuff which do a whole bunch of things like run a PHP application or serve files to dealing with bike range and stuff like that, okay any question, okay but I think we're done. Thank you, I think we're going to have more time for the questions during the break. Yeah, exactly.