Python for Entrepreneurs Transcripts
Chapter: Course Conclusion
Lecture: The final Pyramid cookiecutter template

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Now you've learned so many things, and one of the things we spent a lot of time with was let's start from a beginning pyramid web application,
0:10 and let's add a bunch of things to it, let's add handlers, let's add form handling
0:15 let's ad data access, let's add Rollbar, let's add logging and on and on and on.
0:20 We added all of these things, and if you want to start over for your own project,
0:26 one possibility would be to take the source code like near the end of the project
0:31 and adapt that to your business, but this might be a better option here-
0:35 so what I've done is I've taken all of the ideas and the learning from the course
0:40 that we're working on, and I've bundled them up into a cookiecutter template so that means you just need to run a single CLI command
0:47 and you'll be in a much more customized place with your own settings and everything to get started with something that's more or less
0:57 the final app that we are working with. Here's the cookiecutter template, if you browse through here
1:01 you can see things, it's like better factored to organized it has a master layout, chameleon language, it has handlers,
1:07 user management with passlib, bootstrap already integrated, error monitoring, logbook, all of these different things,
1:15 it even has a cms which we haven't even talked about in the course. All of these things have been added here for.
1:22 Now let me just show you how to use this. So let's start out entirely from scratch, let's go to the desktop here
1:28 and let's mkdir testing or experimenting or whatever, you can put this where you really put your code
1:35 now I want to start as if this is a brand new machine maybe you don't have everything set up on this particular machine
1:41 so let's start by having a virtual environment; so here we'll create virtual environment .env in Python 3
1:48 and then we'll activate it, all right so use the dot to apply that to the shell you can see our prompt has changed to .env,
1:55 that means this is activated so if I do like a pip list you'll see there's only two things, let's go ahead and notice set of tools that's pretty old,
2:03 so let's just do this. So we'll run this command, pip install-u for upgrade set of tools, because there's actually
2:11 that is something like eight versions higher so the things we're going to do later probably are better off having that;
2:19 so now we just have these two things, what we're going to do is we are going to need these cookiecutter, we're going to install cookiecutter
2:29 I've already downloaded it, but you just might come of the internet that's all set up well and god, so all we have to do is say cookiecutter
2:35 and that url that we got from github, right there, mikeckennedy/cookiecutter-pyramid-talk-Python-starter
2:43 first time you run this it will ask no questions and it won't ask this question anyway
2:46 but because I've already got it it'll ask me to verify to get a new version. Now it's going to ask for a project name, be a little careful here
2:53 if you name things like test or something, if you name it a thing that is already a Python package, in Python,
2:58 that's a bad name, I'll call this the web app, like this. Notice it's going to guess the_underscore_web_app, try to take a shot at that
3:07 this would be talk Python, and let say this is it says suggest contact@talkPython, we can give a description for all the metatags
3:16 and then if we have our API key for MailChimp and our smtp server set up
3:22 and our Rollbar account set up, all of those things we could just type them here
3:26 and it would automatically set it all up, but that's not what happened here
3:30 it's not really worth doing, right, you just have those keys working basically. So now if we look here, we have the web app, let's go into the web app
3:40 and notice a couple of things, we have a requirements, this is the thing you should install or the set of things you should install for production
3:48 and then this here, actually pulls those in, and adds a bunch of other stuff that we're going to need for development.
4:00 So what we need to do is a couple of things, we could say Python develop that's one of the things we have to do
4:07 it will install a bunch of stuff, and give us little message to carry on at the end.
4:10 Okay, that all ran well, and it says look, you should make sure you install if you're doing dev work you should also do this
4:19 pip 3 because we have a virtual environment, it doesn't matter pip, pip3 install -r requirements-dev, so this is all the stuff like testing
4:27 and the debug toolbar stuff like that that we'll need to run locally. Now the last thing to do is just p serve,
4:37 the either development.any or production.any we'll pick the development, because hey, this is develop machine
4:45 and look at that, all of our logging, all the stuff that we've added here
4:48 initializing logging, level info, the Python version is 3.6.1 at the time of this recording,
4:53 here is all of the versions that we depend upon, including our Python version up there
4:58 and it looks like we're running in dev mode with this being our database, all of this should look entirely familiar, right,
5:05 this all comes from the various stages of this course. So let's pull this up and see what we get here, and look at that,
5:11 the web app, right here, this is the web app app and you can go and cruise around, you could even sign in and register
5:18 to actually use the database that's there, you can play around to cms page here's a dynamic cms page, you can use for your site,
5:25 the mailing list would work if you had put your id in there and even you get a little copyright, all that kind of stuff down there.
5:32 If you want to get started on a project, after you've taken this course, and you want to kind of use the same ideas,
5:39 probably the easiest way to do that would be to use cookiecutter and this cookiecutter template to start from more or less the end state
5:46 but entirely customize it with your web site name and your keys and all that stuff.

Talk Python's Mastodon Michael Kennedy's Mastodon