Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Applied web development
Lecture: Installing Pyramid Handlers
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Let’s get started with these handlers. Well, the first thing we have to do is to "pip install" them,
0:07
they are an external package that doesn't come by default with the scaffold, so we are going to go install it.
0:13
Now, there are a couple of way in which we can install it, I'll show you a third way that is good for now
0:17
but also a little more helpful when we get to the deployment stage of things. So we could "pip install" using the package manager in PyCharm,
0:26
so if you hit Command+, on OS10, that is "settings" in basically any OS10 app,
0:31
you just go to the settings, project interpreter you can see there is no in here, there is no Pyramid handlers, so we can easily add that,
0:40
go over here and just say pyramid_handlers and pick that, and see, written by Chris McDonough,
0:47
here is how I could just click this button, "boom, installed". So that's a good start, the other thing we could do is go over to terminal
0:54
and activate our virtual environment that we are using, so once we've activated it, we could "pip install pyramid_handlers",
1:06
I could hit Enter there and that would work, but neither these help tell the deployment system:
1:12
"Hey, in order to run this web app you are going to need Pyramid handlers." So if we go over here to the setup.py, remember,
1:18
a Pyramid web apps are a Python packages, they have requirements, so we could come over here and say you know what, we have a new requirement,
1:26
we are going to use Pyramid handlers. And right away, PyCharm says oh, you have some requirement that is not satisfied,
1:33
I could click this or I could just go "Tools, Run setup.py..." and I guess I'll do it this way, "develop", just to show you,
1:42
it's easy to see how to click the button. So if I run this, it will realize "oh, we need this Pyramid handlers"
1:47
and you can see now the requirement installation dialog went away, because we just installed that along with verifying we have everything else
1:54
but of course, we've been running this throughout the whole course, everything else was already there.
1:59
Now one final thing to use Pyramid handlers in our web app is to add a "config include pyramid_hanlders", so
2:09
Pyramid actually loads that up and that will make it possible for us to call "config.add_handler" in addition to or instead of "config.add_route".
2:20
Now let's go and run this just to make sure everything is hanging together correctly,
2:24
and it looks like it is, pull the website up, and there we have it, still looks more or less like the starter scaffold,
2:30
but we are going to address that pretty soon.