Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Your first Pyramid site
Lecture: Project structure

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's take a quick tour
0:01 of the directory structure, or the file structure
0:03 that we have for our pyramid project
0:04 so you can see what, how they've organized it
0:07 and what all the pieces mean.
0:09 Regardless whether you've created this in PyCharm
0:12 or you've created it using Cookiecutter
0:13 on the Command line
0:14 you'll get the same basic output.
0:16 So over here, we'll have our directory
0:20 here it's called make_your_project.
0:22 This is basically the top level package
0:24 that represents our website.
0:26 So in here we have a static directory.
0:28 This is where CSS, JavaScript, and Images go.
0:31 You don't have to drop them all flat in there, right?
0:34 That's how the templates work
0:37 but I would create a css folder, an images folder
0:39 a javascript folder, maybe even more than that.
0:42 So any, sort of, directory structure
0:44 you want to create underneath there, it's totally fine.
0:47 Then the dynamic HTML templates live in templates.
0:50 And PyCharm colors them purple
0:52 but there's nothing really special about that directory.
0:55 When our app starts up
0:57 it's going to run this
1:00 and there's a main method in there that gets executed.
1:03 So that is the entry point for your app
1:06 that's where all the initial setup goes
1:08 where we register the route
1:10 and maybe we read the database configuration
1:12 and get it all set up, things like that.
1:15 We're going to talk about how to test your web applications
1:18 and one of the real big advantages of Pyramid is
1:20 it's super, super testable.
1:22 We'll talk about how to do that
1:25 and it's really, really nice.
1:27 And finally, where your views or controller methods go
1:30 this is right now, a single file.
1:34 That might be okay for a really simple app
1:37 but in practice, we'll want more organization for our tests
1:40 and more organization for our views, even templates.
1:43 So, consider this the starting point
1:46 but as we build this up, I'll show you ways
1:48 where you'll probably want to reorganize things as if
1:51 you know, if this is going to be a real major application.
1:55 That's how it starts out, just a test file and a view file.
1:59 Now, this .egg_info thing, this is an artifact
2:03 from running python develop
2:06 and it's needed for Python to do its magic
2:08 but you can just ignore it, okay?
2:10 So it's going to be there, but just ignore it
2:12 it's part of the register of this package
2:15 for development mode.
2:17 We have our two project settings and configuration files.
2:21 We've gone over this a few times
2:22 but development.ini, that's what you want for dev
2:24 production for production, probably, things like that.
2:28 And that's really all you need to mess with.
2:29 Maybe, maybe?
2:31 If you're going to add a dependency
2:33 or something like that in there
2:34 but this is a starting place.
2:35 So you know how and where to go look for what you need.
2:39 Typically you're going to be in
2:41 in views, in templates, dropping stuff into static.