Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Chameleon templates
Lecture: Launching an existing project

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright so let's write some code and let's interact with these templates here. So lets go over here to our get repository and in chapter five templates
0:10 I'm going to start on this which is right now the same as the starter code, but obviously when I'm done
0:15 it's going to be whatever we did during this chapter. So what we want to do is is we want to take this starter site that we created
0:22 this Py PI site we created in the previous chapter and I want to do interesting stuff with the templates.
0:29 Because we really just ran the cookie cutter before we could do that again but I do want to take this opportunity
0:34 to show you how to take an existing pyramid web app and get it set up and ready to launch in PyCharm. So there's a couple of things we could do.
0:44 We could open in PyCharm and use some of the UI tools or we could use the command line and then open in PyCharm. That's what I like to do.
0:52 Whichever you're more comfortable with just go with that. So what do we need to do to get this started?
0:56 This will basically be the same thing you need to do every step along the way that you want to launch and run something you've gotten from GitHub
1:04 for these projects, so it's worth going over. So what I'm going to do is I'm going to go to the folder that has
1:09 a production and development.ini in there. So I want to cd over there like that, and I want to make sure there's no hidden files.
1:21 We have no hidden .env or anything. We'll call it venv so it doesn't hide. It will be more obvious for examples. We got to do just a couple of things.
1:30 We need to create a virtual environment so that's Python3 -m venv. In Windows, you can't put the 3 but you got to make sure it's Python3
1:41 that is Python in the path. It's a little trickier. Really wish they would unify that but it is what it is. Okay, so when I do that
1:49 and then we're going to run, we're going to activate it so we're going to say source. Sometimes you'll see people say. It means the same thing.
1:56 source venv/bin/activate There's the prompt. It should change and again which or where Python. It should be that one. It's good.
2:05 Once we've activated it, then the last thing to do is simply to run the setup so it would say Python setup.py develop.
2:12 Let it install and everything and we're good to go. Great, with that in place, we can put away our terminal.
2:21 Now, I want to open this directory in PyCharm. On Windows and Linux, you have to go open PyCharm, and say file open directory and browse here.
2:29 On macOS, there's a little treat. I can drop this folder here and it will just open that directory. And start PyCharm.
2:37 All right, so a couple of things happened. Let's expand this out here. PyPI templates. Ah, no, that is not the template folder.
2:44 I guess the name kind of freaked out so you can come over here on marked directory and mark it as that. And right click here.
2:52 Save marked directory as template. While we're at it, might as well go ahead and right click and mark directory as resource route.
3:02 We'll see where that makes sense later but those two things are good. Okay, so this is up and running and we can actually run it.
3:10 Notice it's already detected this. Let's see if it's using the right virtual environment. Click here. It looks like it is.
3:16 Could ask which Python or where Python depending on your OS and yeah, that looks like the one we want. So, okay, everything's great.
3:23 We should be able to, once it's done indexing, click this. Here we have it. Same app, you can see here's the one from before.
3:31 Here's the one that we got from Cookiecutter. Okay, great, so looks like everything is up and running. If you get an error that the port is in use
3:40 that means it's already run it somewhere else. A nice little trick, notice it's running here if I try to run it again, it'll crash.
3:48 It says it's already in use so a quick little trick we can go over here to Edit Configurations, and say only let one of these run.
3:55 That way, if I try to run it instead of just running another it's going to rerun this one here. So, we can just rerun it, rerun it.
4:02 That's super helpful. Okay, so that's what we did to get this up and running in PyCharm. We went there, we created the virtual environment
4:09 we activated it, we did the Python set up. py develop, and then we opened that directory. The very same directory
4:17 that contains the virtual environment. That's the one we'd open. That's the one with the production and development.ini.
4:28 Now we're ready to go play with the templates and we'll go over this in the subsequent videos and subsequent demos
4:33 but I just wanted to make sure we kind of covered that somewhere in the course. Might as well do it the first time we hit it.


Talk Python's Mastodon Michael Kennedy's Mastodon