Building data-driven web apps with Pyramid and SQLAlchemy Transcripts
Chapter: Your first Pyramid site
Lecture: Creating the starter project CLI

Login or purchase this course to watch this video and the rest of the course contents.
0:00 I don't know how you feel,
0:01 but I think there has been enough talking.
0:03 It's time to write some code
0:04 and start creating some software.
0:07 So, that's what this chapter kicks off.
0:09 We're going to create our first project.
0:11 And we'll see that there's actually
0:12 a couple ways to do this
0:13 either with a command-line interface
0:14 which applies everywhere
0:16 or a simplified, shorter way with PyCharm.
0:19 I'll show them both of you.
0:21 But let's talk about how we get started
0:23 in Pyramid in general.
0:25 So, every web framework has its own style of scaffolding
0:29 or the putting the structures in place
0:31 so you can get started.
0:33 So, here, what we're going to use
0:34 is a thing called Cookiecutter.
0:36 So, Cookiecutter is an arbitrary Python utility
0:40 that takes starter projects for all sorts of things
0:43 for Pyramid web apps
0:44 but also for Flask and Django,
0:47 and even old Atari-type things written in C
0:50 and you can create projects from them
0:53 and sort of get a headstart on that structure.
0:56 So, we're going to use the Cookiecutter packages
0:59 for Pyramid to do this.
1:00 This is the official way recommended by the Pyramid folks.
1:04 Once we've installed Cookiecutter
1:06 just pip install cookiecutter,
1:07 we're going to use it to create a site.
1:10 Now there's several different types
1:13 of templates we could use.
1:15 Within those projects
1:16 we have choices like what templating engine
1:19 do you want to use, or things like that.
1:21 So, there's a lot of flexibility here
1:22 but we'll just start with what they call the starter site.
1:26 We're going to create a virtual environment.
1:27 This typically, the virtual environment you want that
1:29 to reflect what you're running on the server
1:32 what your target environment is
1:33 and the way to control that really carefully
1:35 is have a dedicated separate Python environment
1:37 for your web app.
1:39 So, we'll do that here.
1:40 Not required, but very much recommended.
1:43 And then we're going to register the site as a package.
1:46 Pyramid's decided that their web applications
1:48 are best deployed as packages
1:51 and manages packages.
1:52 So, we'll see that there's an extra command
1:55 that you have to run here and say
1:56 "Here's the package that I'm working on,
1:58 "install it into this Python environment."
2:00 Not much to do
2:01 but it's easy to forget
2:02 so I'll show you how to do that.
2:04 And finally, we're ready to run our application.
2:06 We're going to serve it up, interact with it.
2:08 We'll add some features,
2:10 and then we're going to go back
2:12 serve it up again, test it
2:13 and we'll just keep adding and adding and iterating.
2:15 So, these first four steps,
2:17 we're going to do to get started
2:18 and of course, you just build software over time
2:21 by adding feature after feature after feature.
2:25 And so as I said in the opening,
2:27 we can use PyCharm or we can use the command-line.
2:29 First, let's talk about a way of doing this
2:32 that works for everybody no matter what OS you're on
2:35 no matter what tooling you're using.
2:37 This command-line interface path will work for you.
2:40 It takes a couple steps
2:41 but once you get used to it
2:42 it's no big deal at all.