Adding a CMS to Your Pyramid Web App Transcripts
Chapter: A tour of our demo application
Lecture: Getting the app up and running

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Before we move on from this topic I want to show you how to get this code up and running because we're gonna have different versions of this Web app
0:08 and getting it from GitHub and then getting it configured so it'll run correctly is something you have to do a lot in this course Let's do that
0:17 Now we're over here in the GitHub repository. I'm gonna copy the base URL from the top for a sec. I'm going to need that.
0:22 Now if we go over here and see each chapter has starter code. And basically, the way it works is this is the code I just showed you.
0:30 Over here, this is the code that we're gonna have when we're finished with chapter four.
0:35 Right now it says starter code. It's a copy of the previous one. But that's because we're on Chapter 3.
0:39 We're going to Chapter 4. At the end of Chapter 4 this will be the final version of Chapter 4.
0:44 Then there'll be a 5, which will be the final version of Chapter 5 and so on.
0:47 So, depending where you wanna or to jump around and the course you can seek through here.
0:52 So what we're gonna do? You wanna clone this somewhere and I'm just gonna put it on the desktop. I don't like to keep stuff on the desktop.
0:57 You can see it's nice and clean, but just for this example. We're going to 'git clone' this and it's a huge long name
1:03 So I'll just say 'CMS Course' or something like that, All right and then we can go into our CMS course. Here.
1:11 And here, well Surprise, the same structure. Now notice in each one of these, there's a PyPI folder. That's the top level project folder.
1:18 So this is the thing you want to work with and I have this cool little extension that will let me just open command prompt here into this folder.
1:24 So what we want to make sure is, when we look that this '' is where we're working and
1:31 we're in the PyPI folder it has that And I point that out because there's sub PyPI folders as well. That's just how it works with this package.
1:38 So what we're gonna do is we're gonna come over here and create a virtual environment, like so. Then we're going to activate it
1:48 Now, on Linux and macOS, you say 'dot' and then 'bin/activate' On Windows, you would just say 'venv /script/activate.bat'.
1:57 Basically, they avoid the dot Okay, so now we're close to getting it to run. There's a couple of things we have to do for Pyramid to make it run.
2:06 Now, Pyramid is what's called a Python package, and that's how it's distributed.
2:11 So we need to set it up so that it will actually know about itself so that it will run here and
2:16 the way that we're gonna do that is we're gonna run 'Python setup'. We're gonna run the, and want to give it the 'develop' command.
2:23 What that's gonna do is going to set it up and install the dependencies that we need, such as Pyramid and SQLAlchemy and so on.
2:31 Alright, it looks like that's all working. We could do a quick 'pip list' and
2:36 you can see all the things that looks like we're needing, chameleon, pyramid and so on are here.
2:41 And also PyPI is installed locally right there. That just means it knows about itself basically.
2:47 Our pip is out of date, but that's just the way these things work. We can upgrade it, but not worth bothering about now.
2:54 Okay, so we've got it set up. We have our virtual environment active, and now we just want to see if we can run it
3:01 When I ran 'Python develop' it installed Pyramid. Pyramid comes with a command called 'pserve'.
3:07 Like that, and what we do is we give it the '.ini' the configuration file that we want to run and we want to run, develop.
3:15 In production and out on the Internet, we would run production Here, we're working on it in development, so hence development.
3:21 So let's hit it with this. Now, sometimes you get this weird 'This is not found'. Watch this. This is annoying.
3:28 If we deactivate our virtual environment and then we reactivated and then we try this again
3:36 Well, guess what it's found. Well, thanks Python for that inconsistency,
3:41 but I'm kind of glad I ran into because if you run into that problem, you could see it's super easy to fix.
3:45 And now, let's just copy this and make sure it's running over here. Here we go, Up and running. Everything's working. Great.
3:52 The final thing, maybe you want to see how you get this into PyCharm.
3:58 We're gonna go over here and take the folder that contains a '' and drop that into PyCharm like so.
4:04 On Windows and Linux, you have to say file, open directory, Mac OS, you can drop it on the middle dock icon there
4:12 Notice it's already found PyPI, So that's good. We should be able to run something And if we go down here, we can find our code again.
4:21 Yeah, that's that's good. One quick little trick we can do to make things work better in our HTML files
4:27 We can go over here and say 'mark directory as resource route'
4:31 So when you say, like '/static', it knows to look at this folder and it'll autocomplete, like out through there. That's very nice
4:37 Okay, so this looks pretty much ready to go. Let's double check that it's using our virtual environment.
4:44 And yeah, it looks like that is the case. Yeah, that's the one we created. Cool Cool.
4:51 It doesn't always work, and if it doesn't work you can go to the preferences or settings on the other OS's
4:57 Go to the project, project interpreter, should be listed over here. If it's not, you can 'Add', then click 'Add Existing' and probably find it for you.
5:07 But it worked for us, so we don't need to do that. Click 'go' running just like before There we go. We have it working in PyCharm as well
5:15 All right, so that's basically the process that you need to go through each time. One quick note is, don't reuse these virtual environments
5:22 This is Chapter 3, you want one for the Chapter 3, one for Chapter 4, one for Chapter 5.
5:27 because when you install the project itself as the package, it points over to that location where it came from
5:35 So you don't wanna have it use the old code or part of the old code and part of the new code.
5:40 It's very messy, so just make sure that you always use a new virtual environment for every chapter
5:44 and just go through that process and double check that PyCharm, if you're using PyCharm, is discovering it correctly
5:50 You can quickly come over here in the terminal and see that it has one active And ask 'which Python'.
5:55 On windows you can type 'where Python' and it will show you which one that's using. Looks like this one is all set and we're ready to go.
6:03 You should be ready to start building from this demo app.

Talk Python's Mastodon Michael Kennedy's Mastodon