Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Part 1
Lecture: Introducing Pyramid Building Blocks
Login or
purchase this course
to watch this video and the rest of the course contents.
0:02
Let's talk about the building blocks that you are going to use to build your application when you are using Pyramid.
0:09
The first thing that we want to do is take a request from the outside world and somehow map this into our application and that all begins with routes,
0:17
routes are URL patterns that we then map into particular view methods, speaking of views, these are the methods that are going to process our request,
0:26
whether they show us an HTML page through rendering a template or make some kind of update to a database and do a redirect,
0:33
that's where we are going to do it, is it in these view methods. And note that in MVC, these are called controllers.
0:40
Next, we are going to talk about templates, typically what we'll do with our views is we'll come up with some sort of data
0:46
and then we'll pass that off to a dynamic template and this template is going to take that data
0:51
and turn it into HTML that actually goes back to the user. The thing that flows between the views and the templates are called models,
1:00
and these are basically dictionaries in Python and this is both data and behavior that we can pass to the view.
1:07
Pyramid has rich support for static assets, so images, cascading style sheets, JavaScript and more, we'll be able to manage those separately,
1:17
more or less offloading the request out of our web app and passing it just to the web server itself. We also want to work with configuration files,
1:25
you want to put your API keys and other sorts of information like that
1:29
into the configuration files and these are often different between dev, tests and prod.