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, but I think there has been enough talking. It's time to write some code and start creating some software.
0:08 So, that's what this chapter kicks off. We're going to create our first project. And we'll see that there's actually a couple ways to do this
0:14 either with a command-line interface which applies everywhere or a simplified, shorter way with PyCharm. I'll show them both of you.
0:22 But let's talk about how we get started in Pyramid in general. So, every web framework has its own style of scaffolding
0:30 or the putting the structures in place so you can get started. So, here, what we're going to use is a thing called Cookiecutter.
0:37 So, Cookiecutter is an arbitrary Python utility that takes starter projects for all sorts of things for Pyramid web apps but also for Flask and Django,
0:48 and even old Atari-type things written in C and you can create projects from them and sort of get a headstart on that structure.
0:57 So, we're going to use the Cookiecutter packages for Pyramid to do this. This is the official way recommended by the Pyramid folks.
1:05 Once we've installed Cookiecutter just pip install cookiecutter, we're going to use it to create a site. Now there's several different types
1:14 of templates we could use. Within those projects we have choices like what templating engine do you want to use, or things like that.
1:22 So, there's a lot of flexibility here but we'll just start with what they call the starter site. We're going to create a virtual environment.
1:28 This typically, the virtual environment you want that to reflect what you're running on the server what your target environment is
1:34 and the way to control that really carefully is have a dedicated separate Python environment for your web app. So, we'll do that here.
1:41 Not required, but very much recommended. And then we're going to register the site as a package. Pyramid's decided that their web applications
1:49 are best deployed as packages and manages packages. So, we'll see that there's an extra command that you have to run here and say
1:57 "Here's the package that I'm working on, "install it into this Python environment." Not much to do but it's easy to forget
2:03 so I'll show you how to do that. And finally, we're ready to run our application. We're going to serve it up, interact with it.
2:09 We'll add some features, and then we're going to go back serve it up again, test it and we'll just keep adding and adding and iterating.
2:16 So, these first four steps, we're going to do to get started and of course, you just build software over time
2:22 by adding feature after feature after feature. And so as I said in the opening, we can use PyCharm or we can use the command-line.
2:30 First, let's talk about a way of doing this that works for everybody no matter what OS you're on no matter what tooling you're using.
2:38 This command-line interface path will work for you. It takes a couple steps but once you get used to it it's no big deal at all.


Talk Python's Mastodon Michael Kennedy's Mastodon