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